Skip to content

Commit

Permalink
Merge branch 'main' into Main_AmitM_Feature_CustomEncryptionDecryptio…
Browse files Browse the repository at this point in the history
…n_21Jan
  • Loading branch information
Mrinank-Bhowmick authored Feb 10, 2024
2 parents 220c573 + 451ad51 commit 7090184
Show file tree
Hide file tree
Showing 20 changed files with 745 additions and 397 deletions.
682 changes: 348 additions & 334 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion projects/Diabetes Monitoring Dashboard/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ openai==0.27.2
pandas==1.3.5
Requests==2.31.0
scikit_learn==1.2.1
streamlit==1.22.0
streamlit==1.30.0
streamlit_lottie==0.0.5
75 changes: 75 additions & 0 deletions projects/File_Organizer/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import argparse
import os
import logging
import shutil # For moving files

def main():
try:
args = parse_arguments()
check_directory(args.directory_path)

setup_logging(args.verbose)

organize_directory(args.directory_path)
# Catch any exceptions that may occur
except Exception as e:
print(e)

def parse_arguments():
# Parse the arguments from cli, order is irrelevant
parser = argparse.ArgumentParser(description="Organize files in a directory based on their extensions.")
parser.add_argument("directory_path", type=str, help="Path of the directory to be organized") # Required argument
parser.add_argument("-v", "--verbose", action="store_true", help="Enable verbose output") # Optional argument
return parser.parse_args()

def check_directory(directory_path):
if not os.path.isdir(directory_path):
raise ValueError(f"'{directory_path}' is not a valid directory.")

if not os.listdir(directory_path):
raise ValueError(f"'{directory_path}' is an empty directory!")

if not os.access(directory_path, os.W_OK):
raise ValueError(f"'{directory_path}' is not writable.")

def setup_logging(verbose):
log_level = logging.INFO if verbose else logging.WARNING
log_format = "%(message)s"
logging.basicConfig(level=log_level, format=log_format)

def organize_directory(directory_path):
categories = {
"Music": (".mp3", ".wav", ".flac", ".m4a", ".aac", ".ogg", ".oga", ".wma", ".mid",),
"Videos": (".mp4", ".avi", ".mkv", ".mpeg", ".wmv", ".vob", ".flv", ".mov", ".3gp", ".webm",),
"Source Files": (".py", ".c", ".cpp", ".java", ".js", ".cs", ".html", ".css", ".php", ".json", ".xml", ".sql", ".db",),
"Executables": (".exe", ".msi", ".sh", ".bat", ".apk", ".jar", ".deb", ".run", ".bin", ".dmg", ".iso",),
"Pictures": (".jpg", ".jpeg", ".png", ".gif", ".bmp", ".svg", ".webp", ".psd", ".ai", ".ico",),
"Documents": (".pdf", ".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".txt", ".md", ".odt", ".ods", ".odp", ".csv", ".rtf",),
"Compressed": (".zip", ".rar", ".tar", ".gz", ".7z", ".bz2", ".xz", ".z", ".lz",),
"Torrents": (".torrent",),
}

for category, extensions in categories.items():
# Check if there are files with matching extensions for this category
files_with_extension = [file for file in os.listdir(directory_path) if os.path.isfile(os.path.join(directory_path, file))
and os.path.splitext(file)[1].lower() in extensions]

if files_with_extension:
# Create a folder for this category if it doesn't exist
category_folder = os.path.join(directory_path, category)
if not os.path.exists(category_folder):
os.makedirs(category_folder)
logging.info(f"Creating '{category}' folder.")
else:
logging.info(f"'{category}' folder already exists, reusing.")

for file in files_with_extension:
source_path = os.path.join(directory_path, file)
dest_path = os.path.join(category_folder, file)
shutil.move(source_path, dest_path)
logging.info(f"Moved '{file}' to '{category}' folder.")

print("Organizing files complete!")

if __name__ == "__main__":
main()
6 changes: 3 additions & 3 deletions projects/Guess Number/guess_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ def guess(num, user_guess):
print(f"\nNumber is higher than {user_guess}")
lower_limit = user_guess
user_guess = enter_and_verification(lower_limit + 1, upper_limit)
num_of_guesses=num_of_guesses+1
num_of_guesses = num_of_guesses + 1
elif num < user_guess:
print(f"\nNumber is lower than {user_guess}")
upper_limit = user_guess
user_guess = enter_and_verification(lower_limit, upper_limit - 1)
num_of_guesses=num_of_guesses+1
num_of_guesses = num_of_guesses + 1
else:
print()
print(f"\nCongrats! You've guessed the correct number! It was {num}.\n")
Expand All @@ -51,7 +51,7 @@ def guess(num, user_guess):
while True:
play_y_n = input("Welcome to Number Guesser. If you'd like to play, press 'Y': ")
if play_y_n.lower() == "y":
num_of_guesses=0
num_of_guesses = 0
num = random.randint(smaller_number, larger_number)
user_guess = enter_and_verification(lower_limit, upper_limit)
guess(num, user_guess, num_of_guesses)
Expand Down
7 changes: 5 additions & 2 deletions projects/Instagram Post Creation/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

from PIL import Image, ImageDraw, ImageFont


def create_instagram_post(template, text, output_path):
# Load the template image
template_path = os.path.join(os.path.dirname(__file__), "templates", "basic_template.jpg")
template_path = os.path.join(
os.path.dirname(__file__), "templates", "basic_template.jpg"
)
img = Image.open(template_path)

# Initialize the drawing context
Expand Down Expand Up @@ -34,4 +37,4 @@ def create_instagram_post(template, text, output_path):
post_text = "My Instagram Post"
output_file = "output/post.jpg"

create_instagram_post(template_name, post_text, output_file)
create_instagram_post(template_name, post_text, output_file)
44 changes: 19 additions & 25 deletions projects/Internet-speed-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,48 @@
**This is a internet speed tester made in python**

## Getting Started

- Clone this repo
- Run the following commands -
```
- Run the following commands -

```bash
pip install requirements.txt
```

OR
```

```bash
pip3 install requirements.txt
```

- Then
```

```bash
python main.py
```

OR
```

```bash
python3 main.py
```

## Libraries
speedtest-cli
```
pip install speedtest-cli
```
OR
```
pip3 install speedtest-cli
```

## Troubleshooting
if you have an error of "AttributeError: module 'speedtest' has no attribute 'Speedtest'" when running
following https://stackoverflow.com/questions/66249874/python-speedtest-has-no-attribute-speedtest

try:
speedtest-cli

First
```
pip uninstall speedtest
```
Followed by
```
```bash
pip install speedtest-cli
```
and then run again

OR

```bash
pip3 install speedtest-cli
```

## Author

![Shreejan-35](https://github.com/Shreejan-35)

That's all.
3 changes: 1 addition & 2 deletions projects/Internet-speed-test/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
speedtest==0.0.1
speedtest_cli==2.1.3
speedtest_cli
8 changes: 4 additions & 4 deletions projects/Message-Spam/mesaage_spam.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
time.sleep(10)

# List of messages to send
messages = ('Hello', 'Hey', 'Good Morning')
messages = ("Hello", "Hey", "Good Morning")

# Send 10 random messages
for _ in range(10):
# Choose a random message from the list
message = random.choice(messages)

# Type and send the message using PyAutoGUI
pg.write(message)
pg.press('enter')
pg.press("enter")

# Pause for a random duration between 1 to 3 seconds
time.sleep(random.uniform(1, 3))
90 changes: 90 additions & 0 deletions projects/Organize_Directory/organizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import os
import shutil


def main():
dir_path = input("Enter the directory path of the files: ")

try:
print(
"Organising your files into [ images - music - video - executable - archive - torrent - document - code - design files]"
)
for filename in os.listdir(dir_path):
absname = os.path.join(dir_path, filename)
# Check if files are images and you can add more extensions
if filename.lower().endswith(
(".png", ".jpg", ".jpeg", ".gif", ".bmp", ".pbm", ".pnm")
):
# If images folder doesn't exist then create new folder
if not os.path.exists("images"):
os.makedirs("images")
shutil.move(absname, "images")

# Check if files are music and you can add more extensions
elif filename.lower().endswith(
(".wav", ".mp3", ".flac", ".3gp", ".aa", ".aax", ".aiff", ".raw")
):
# If music folder doesn't exist then create new folder
if not os.path.exists("music"):
os.makedirs("music")
shutil.move(absname, "music")

# Check if files are videos and you can add more extensions
elif filename.lower().endswith((".webm", ".mp4")):
# If video folder doesn't exist then create new folder
if not os.path.exists("video"):
os.makedirs("video")
shutil.move(absname, "video")

# Check if files are executables
elif filename.lower().endswith((".exe", ".msi", ".deb", "dmg")):
# If executables folder doesn't exist then create new folder
if not os.path.exists("executables"):
os.makedirs("executables")
shutil.move(absname, "executables")

# Check if files are archive files
elif filename.lower().endswith((".rar", ".tar", ".zip", ".gz")):
# If archive folder doesn't exist then create new folder
if not os.path.exists("archives"):
os.makedirs("archives")
shutil.move(absname, "archives")

# Check if files are torrent files
elif filename.lower().endswith((".torrent",)):
# If torrent folder doesn't exist then create new folder
if not os.path.exists("torrent"):
os.makedirs("torrent")
shutil.move(absname, "torrent")

# Check if files are documents
elif filename.lower().endswith((".txt", ".pdf", ".docx", "doc")):
# If documents folder doesn't exist then create new folder
if not os.path.exists("documents"):
os.makedirs("documents")
shutil.move(absname, "documents")

# Check if files are code files
elif filename.lower().endswith((".py", ".php", ".html", ".css", ".js")):
# If code folder doesn't exist then create new folder
if not os.path.exists("code"):
os.makedirs("code")
shutil.move(absname, "code")

# Check if files are design files
elif filename.lower().endswith((".psd", ".ai")):
# If design folder doesn't exist then create new folder
if not os.path.exists("design-files"):
os.makedirs("design-files")
shutil.move(absname, "design-files")

except OSError:
print("Error happened ...... try again")
finally:
# When script is finished clear screen and display message
os.system("cls" if os.name == "nt" else "clear")
print("Finished organising your files")


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion projects/QRCode-Generator/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
colorama==0.4.5
comtypes==1.1.11
Pillow==10.0.1
Pillow==10.2.0
pypiwin32==223
pyttsx3==2.90
pywin32==304
Expand Down
4 changes: 2 additions & 2 deletions projects/QuickWordCloud/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ black==22.8.0
click==8.1.3
contourpy==1.0.5
cycler==0.11.0
fonttools==4.37.4
fonttools==4.43.0
iniconfig==1.1.1
kiwisolver==1.4.4
matplotlib==3.6.0
mypy-extensions==0.4.3
numpy==1.23.3
packaging==21.3
pathspec==0.10.1
Pillow==10.0.1
Pillow==10.2.0
platformdirs==2.5.2
pluggy==1.0.0
pyparsing==3.0.9
Expand Down
29 changes: 29 additions & 0 deletions projects/Rename_Images/rename_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import os


def main():
img_types = ["jpg", "png", "jpeg"]
dir_path = input("Enter the directory path of the images: ")

for i, f in enumerate(os.listdir(dir_path)):
absname = os.path.join(dir_path, f)
img_type = absname.split(".")[-1]

if img_type in img_types:
while True:
newname = input(f"Enter the new name for {f} (without extension): ")
newname = "{}.{}".format(newname, img_type)
new_absname = os.path.join(dir_path, newname)
if not os.path.exists(new_absname):
os.rename(absname, new_absname)
break
else:
print(
"A file with this name already exists. Please enter a different name."
)

print("Done renaming images.")


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions projects/Resize_Image/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pillow
Loading

0 comments on commit 7090184

Please sign in to comment.