From 922e49b411cadf2e301b868e4414a49f05454a3c Mon Sep 17 00:00:00 2001 From: ibra-kdbra Date: Wed, 17 Jan 2024 21:49:46 +0300 Subject: [PATCH 1/5] removed speedtest as it make conflict with speedtest-cli on python3.5+ --- projects/Internet-speed-test/requirements.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/Internet-speed-test/requirements.txt b/projects/Internet-speed-test/requirements.txt index e7fc6f95a..81f5b451f 100644 --- a/projects/Internet-speed-test/requirements.txt +++ b/projects/Internet-speed-test/requirements.txt @@ -1,2 +1 @@ -speedtest==0.0.1 -speedtest_cli==2.1.3 +speedtest_cli From 55ca8d12c80725dcc67a5c172e7188864bbe4a52 Mon Sep 17 00:00:00 2001 From: ibra-kdbra Date: Wed, 17 Jan 2024 21:50:13 +0300 Subject: [PATCH 2/5] removed troubleshoot section as it's no longer needed --- projects/Internet-speed-test/README.md | 44 +++++++++++--------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/projects/Internet-speed-test/README.md b/projects/Internet-speed-test/README.md index 642cb7f48..eb3c2d6a2 100644 --- a/projects/Internet-speed-test/README.md +++ b/projects/Internet-speed-test/README.md @@ -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. From 2a6ceb5ca52fb84696b4ba564323666b37acf853 Mon Sep 17 00:00:00 2001 From: ibra-kdbra Date: Wed, 17 Jan 2024 23:18:15 +0300 Subject: [PATCH 3/5] resize images(multiple or single) --- projects/Resize_Image/requirements.txt | 1 + projects/Resize_Image/resize.py | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 projects/Resize_Image/requirements.txt create mode 100644 projects/Resize_Image/resize.py diff --git a/projects/Resize_Image/requirements.txt b/projects/Resize_Image/requirements.txt new file mode 100644 index 000000000..5873a2224 --- /dev/null +++ b/projects/Resize_Image/requirements.txt @@ -0,0 +1 @@ +Pillow \ No newline at end of file diff --git a/projects/Resize_Image/resize.py b/projects/Resize_Image/resize.py new file mode 100644 index 000000000..bb7a8a005 --- /dev/null +++ b/projects/Resize_Image/resize.py @@ -0,0 +1,39 @@ +import os +from PIL import Image + +def resize_image(image_path, size): + im = Image.open(image_path) + im = im.resize(size) + return im + + +def main(): + choice = input("Do you want to resize multiple images? (yes/no): ") + width = int(input("Enter the width: ")) + height = int(input("Enter the height: ")) + size = (width, height) + + images = [] + if choice.lower() == 'yes': + dir_path = input("Enter the directory path of the images: ") + for filename in os.listdir(dir_path): + if filename.endswith('.png') or filename.endswith('.jpg'): + image_path = os.path.join(dir_path, filename) + images.append((image_path, resize_image(image_path, size))) + else: + image_path = input("Enter the image path: ") + images.append((image_path, resize_image(image_path, size))) + + output_folder = input("Enter the output folder: ") + os.makedirs(output_folder, exist_ok=True) + + for image_path, im in images: + new_image_name = input(f"Enter the new name for {os.path.basename(image_path)}: ") + output_path = os.path.join(output_folder, new_image_name) + im.save(output_path) + print(f"Resized image is saved as {output_path}.") + + print('Done resizing images.') + +if __name__ == "__main__": + main() From 074a9332175234d81b60a706e6550549d14c4e01 Mon Sep 17 00:00:00 2001 From: ibra-kdbra Date: Wed, 17 Jan 2024 23:37:47 +0300 Subject: [PATCH 4/5] rename mulitple images in a specified directory --- projects/Rename_Images/rename_images.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 projects/Rename_Images/rename_images.py diff --git a/projects/Rename_Images/rename_images.py b/projects/Rename_Images/rename_images.py new file mode 100644 index 000000000..e813d57ae --- /dev/null +++ b/projects/Rename_Images/rename_images.py @@ -0,0 +1,25 @@ +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() From 4042f93c13ab1cf661a16a87e03c14a70d6b7ae9 Mon Sep 17 00:00:00 2001 From: ibra-kdbra Date: Thu, 18 Jan 2024 00:24:19 +0300 Subject: [PATCH 5/5] Organizer the files in the directory you want --- projects/Organize_Directory/organizer.py | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 projects/Organize_Directory/organizer.py diff --git a/projects/Organize_Directory/organizer.py b/projects/Organize_Directory/organizer.py new file mode 100644 index 000000000..cb60ae46a --- /dev/null +++ b/projects/Organize_Directory/organizer.py @@ -0,0 +1,82 @@ +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()