From 3919f46a4c31a2892dd5b45f91cd13a7eade18b1 Mon Sep 17 00:00:00 2001 From: Subhayu Kumar Bala Date: Sun, 16 Aug 2020 10:00:18 +0530 Subject: [PATCH 1/4] Add files via upload --- System-Automation-Scripts/qrGenerator.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 System-Automation-Scripts/qrGenerator.py diff --git a/System-Automation-Scripts/qrGenerator.py b/System-Automation-Scripts/qrGenerator.py new file mode 100644 index 00000000..afcf9f08 --- /dev/null +++ b/System-Automation-Scripts/qrGenerator.py @@ -0,0 +1,20 @@ +import os +import qrcode +from sys import argv +from urllib.parse import urlparse +import random + +if len(argv)==2: + url = str(argv[1]) +else: + url = input("Enter an URL to Encode in QR: ") + +path = ((urlparse(url)).netloc) +image = qrcode.make(url) + +if os.path.exists(f"{path}.png"): + path = path + str(random.randint(0,1000)) + +image.save(f"{path}.png", "PNG") +file_path = os.path.abspath(path) +print("File saved to:", file_path) From aab1c2773914c21095ea3c8e932390d7562c37f7 Mon Sep 17 00:00:00 2001 From: subhayu99 Date: Tue, 18 Aug 2020 10:11:46 +0530 Subject: [PATCH 2/4] qrGenerator --- System-Automation-Scripts/qrGenerator/README.md | 0 .../{ => qrGenerator}/qrGenerator.py | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100644 System-Automation-Scripts/qrGenerator/README.md rename System-Automation-Scripts/{ => qrGenerator}/qrGenerator.py (65%) diff --git a/System-Automation-Scripts/qrGenerator/README.md b/System-Automation-Scripts/qrGenerator/README.md new file mode 100644 index 00000000..e69de29b diff --git a/System-Automation-Scripts/qrGenerator.py b/System-Automation-Scripts/qrGenerator/qrGenerator.py similarity index 65% rename from System-Automation-Scripts/qrGenerator.py rename to System-Automation-Scripts/qrGenerator/qrGenerator.py index afcf9f08..65fd4728 100644 --- a/System-Automation-Scripts/qrGenerator.py +++ b/System-Automation-Scripts/qrGenerator/qrGenerator.py @@ -5,16 +5,16 @@ import random if len(argv)==2: - url = str(argv[1]) + url = str(argv[1]) else: - url = input("Enter an URL to Encode in QR: ") + url = input("Enter an URL to Encode in QR: ") path = ((urlparse(url)).netloc) image = qrcode.make(url) if os.path.exists(f"{path}.png"): - path = path + str(random.randint(0,1000)) + path = path + str(random.randint(0,10000)) image.save(f"{path}.png", "PNG") file_path = os.path.abspath(path) -print("File saved to:", file_path) +print("File saved to:", file_path) \ No newline at end of file From 952bdb9fba5c32651129742ee5f2d17852a0e7da Mon Sep 17 00:00:00 2001 From: Subhayu Kumar Bala Date: Tue, 18 Aug 2020 10:25:56 +0530 Subject: [PATCH 3/4] Update README.md --- System-Automation-Scripts/qrGenerator/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/System-Automation-Scripts/qrGenerator/README.md b/System-Automation-Scripts/qrGenerator/README.md index e69de29b..3dda81a0 100644 --- a/System-Automation-Scripts/qrGenerator/README.md +++ b/System-Automation-Scripts/qrGenerator/README.md @@ -0,0 +1,4 @@ +# qrGenerator + +- A Python Script that asks the user to input an URL or any string of characters and then coverts it to a QR code as the name of the URL domain, saved locally in the current working directory or as specified by the user. +- Can be used either in the Command Line or within the Python IDE From d60f1a98406919bc4cce5edf3e48ca14d4547aa4 Mon Sep 17 00:00:00 2001 From: Subhayu Kumar Bala Date: Tue, 18 Aug 2020 10:29:50 +0530 Subject: [PATCH 4/4] Update README.md --- System-Automation-Scripts/qrGenerator/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/System-Automation-Scripts/qrGenerator/README.md b/System-Automation-Scripts/qrGenerator/README.md index 3dda81a0..11f28139 100644 --- a/System-Automation-Scripts/qrGenerator/README.md +++ b/System-Automation-Scripts/qrGenerator/README.md @@ -1,4 +1,5 @@ # qrGenerator - A Python Script that asks the user to input an URL or any string of characters and then coverts it to a QR code as the name of the URL domain, saved locally in the current working directory or as specified by the user. +- Also, if the program finds an existing QR with the same filename, it creates a new one with a random number at the end of the filename. - Can be used either in the Command Line or within the Python IDE