From 0e9a873838548d49466ef66363d309041a8fa116 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 27 Jun 2021 15:36:06 -0500 Subject: [PATCH 01/35] README with more Sections. install and How use --- README.md | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42b6816..b5ea0d3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,90 @@ # ⚡ CLI_Checker ⚡ -A Holberton School checker tool to avoid using your browser to check manaully every task of your current project. + > A Holberton School checker tool to avoid using your browser to check manaully every task of your current project. + +## How to install + +clone the repo and run the instalation script +```console +$ git clone https://github.com/DiegoCol93/CLI_Checker +$ cd CLI_Checker +$ ./install.sh +$ checker +``` +the program are going to ask for: + - your holberton's __email__ (xxxx@holbertonshcool.com) + - your __API__ key ([link][api_link]) + - it's in the __Intranet > Tools > Holberton's Intranet API key__ + - it's an HEX string of 32 chars ex. `123abc123abcdef99001122cdef12351` + - your intranet's __password__ (it will be hidden so don't worry if you don't see the chars) + +after finishing the credentials it will ask for storing credentials + - note: it has problem so write «__yes__» in lowercase + +## How to use +just run cecker in your terminal ant the checker terminal will start + +```console +$ checker +CLI-Checker ⚡ +``` +Now that you are in the console, you has to select the project with `project `. +The project's number is the last number of the url
+ +#### Example of use +Suppose that you want to check the project __0x00. C - Hello, World__
+The url is `https://intranet.hbtn.io/projects/212`
+So, the project's number is __212__ +```console +CLI-@Checker ⚡$ project 212 +0 - Preprocessor +1 - Compiler +2 - Assembler +3 - Name +4 - Hello, puts +5 - Hello, printf +6 - Size is not grandeur, and territory does not make a nation +7 - What happens when you type gcc main.c +8 - Intel +9 - UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity + + ┌─ You may now run: + │ + └─┬─ check + ├ To check a specific task. + │ + ├─ check Not implemented yet🤕, Sorry. + ├ To check all tasks of current project. + └─┐ + ├─ To check only task 2 you would run + │ + └─ Example: check 2 + +CLI-@Checker ⚡$ check 1 +Task 1 Compiler +Checking your code... 🎉 +🔥 Check 0: Approved 🏆 +⚡ Check 1: Approved 🔥 +🤩 Check 2: Approved 🎊 +🥂 Check 3: Approved 🔥 +``` + +### Available commands + - help: show help. `available` is misspelled + - EOF: (Ctrl-D) finish the console + - quit: finish the console (same as EOF) + - project: select project + - check: slect task + ## Contributors -- Diego Lopez -- Wiston Venera -- Leonardo Valencia +- [Diego Lopez][@DiegoCol93] +- [Wiston Venera][@wsvem] +- [Leonardo Valencia][@4ions] +- [Gustavo Mejía][@Athesto] (README) + + +[api_link]: https://intranet.hbtn.io/dashboards/my_tools +[@Athesto]: https://github.com/Athesto +[@wsvem]: https://github.com/wisvem +[@4ions]: https://github.com/4ions +[@DiegoCol93]: https://github.com/DiegoCol93 From 5a6e290e7c4736797c6e85a00d77cd940adef912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mej=C3=ADa=20S=C3=A1nchez?= Date: Thu, 8 Jul 2021 17:35:28 -0500 Subject: [PATCH 02/35] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index b5ea0d3..42166de 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ # ⚡ CLI_Checker ⚡ > A Holberton School checker tool to avoid using your browser to check manaully every task of your current project. +## Prerquisites +You need the [tools][api_link] section available in the intranet + ## How to install clone the repo and run the instalation script From 3fc1fc3c88a41c0d0d94ee91e370d7e1750ea637 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 09:59:04 -0500 Subject: [PATCH 03/35] autopep8 --- checker.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/checker.py b/checker.py index fa08d56..7f59588 100755 --- a/checker.py +++ b/checker.py @@ -14,8 +14,8 @@ # Color format for text printing. y = '\033[38;5;220m' # Yellow. g = '\033[92m' # Green. -r = '\033[91m' # Red -rs= '\033[m' # Reset. +r = '\033[91m' # Red +rs = '\033[m' # Reset. # Get the size of the tty. size = get_terminal_size() @@ -156,8 +156,6 @@ def start_up(self): else: password = getpass("\033[6;3fPlease enter your password: ") - - # Load custom mock loading Bar... - - - - - - - - - - - - - - - - - - | i = 0 print("\033[6;3f", end='') @@ -180,7 +178,7 @@ def start_up(self): print('\033[92m', end='') print("\033[5;0f", end='') print('┌' + '─' * (columns - 2) + '┐') - print('│' + success_space + success + success_space, end = '│') + print('│' + success_space + success + success_space, end='│') print('└' + '─' * (columns - 2) + '┘') print('\033[m', end='') print("\033[6;3f", end='') @@ -244,23 +242,23 @@ def start_up(self): # Project command - - - - - - - - - - - - - - - - - - - - - - - - - - - - | def do_project(self, arg): """\n""" \ - """ ┌\033[92m─\033[m Fetches and updates the current project.\n""" \ - """ │\n""" \ - """ └─┬\033[92m─\033[m Usage:\n""" \ - """ │\n""" \ - """ ├──\033[92m─\033[m project <\033[92mnum\033[m>\n""" \ - """ │\n""" \ - """ ├\033[92m─\033[m The \033[92mnum\033[m variable represents """ \ - """the number from\n""" \ - """ │ the project's url in your current Holberton proje""" \ - """ct.\n""" \ - """ │\n""" \ - """ └─┬\033[92m─\033[m Example:\n""" \ - """ │\n""" \ - """ ├\033[92m─\033[m From: https://intranet.hbtn.io/projects""" \ - """/\033[92m212\033[m\n""" \ - """ │\n""" \ - """ └\033[92m─\033[m Run: project \033[92m212\033[m\n""" \ + """ ┌\033[92m─\033[m Fetches and updates the current project.\n""" \ + """ │\n""" \ + """ └─┬\033[92m─\033[m Usage:\n""" \ + """ │\n""" \ + """ ├──\033[92m─\033[m project <\033[92mnum\033[m>\n""" \ + """ │\n""" \ + """ ├\033[92m─\033[m The \033[92mnum\033[m variable represents """ \ + """the number from\n""" \ + """ │ the project's url in your current Holberton proje""" \ + """ct.\n""" \ + """ │\n""" \ + """ └─┬\033[92m─\033[m Example:\n""" \ + """ │\n""" \ + """ ├\033[92m─\033[m From: https://intranet.hbtn.io/projects""" \ + """/\033[92m212\033[m\n""" \ + """ │\n""" \ + """ └\033[92m─\033[m Run: project \033[92m212\033[m\n""" \ self.task_dict = get_tasks(arg) @@ -337,10 +335,12 @@ def do_quit(self, arg): """ Quit command to exit the console. """ return True + if __name__ == '__main__': from os import get_terminal_size - space_around = ' ' * ((columns - len('┌───────────────────────────┐')) // 2) + space_around = ' ' * \ + ((columns - len('┌───────────────────────────┐')) // 2) s = space_around CLI_Checker().cmdloop( From 92fc97cd2bd1f20a10c67a1fbec475ab6d81bee7 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 11:44:20 -0500 Subject: [PATCH 04/35] ignore .env file --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index cf34c89..092cf7c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *__pychache__ credentials *pyc +.env +.*.swp From bb20a7c0da074d061905b2144477c2fb8f07ecc8 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 11:47:23 -0500 Subject: [PATCH 05/35] fix answer lower in credentials' question --- checker.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/checker.py b/checker.py index 7f59588..bff3580 100755 --- a/checker.py +++ b/checker.py @@ -194,7 +194,7 @@ def start_up(self): print('└' + '─' * (columns - 2) + '┘') print('\033[m', end='') print("\033[6;3f", end='') - answer = str(input(question)) + answer = str(input(question)).lower() while answer not in self.yes_no_list: print("\033[5;0f", end='') print('\033[92m', end='') @@ -205,10 +205,10 @@ def start_up(self): print("\033[6;3f", end='') answer = str(input("Please answer Yes or No: ")) - if answer.lower() in ['yes', 'y']: with open('/tmp/.hbnb_creds', 'w+') as f: cred = 'Your Credentials have been stored in ' \ '/tmp/.hbnb_creds' + if answer in ['yes', 'y']: json.dump({'email': email, 'api': api, 'password': password, 'token': ""}, f) print("\033[5;0f", end='') @@ -350,5 +350,6 @@ def do_quit(self, arg): s + '│ 🔥' + y + ' Diego Lopez ' + rs + '🔥 │\n' + s + '│ 🔥' + y + ' Wiston Venera ' + rs + '🔥 │\n' + s + '│ 🔥' + y + ' Leonardo Valencia ' + rs + '🔥 │\n' + + s + '│ 🔥' + y + ' Gustavo Mejia ' + rs + '🔥 │\n' + s + '└───────────────────────────┘\n' 'Please run help to see available commands..') From 9fb0860aba6fcae52dcb33a318c3a303fec982ce Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 11:49:22 -0500 Subject: [PATCH 06/35] skip instro if it's if debug variable is on --- checker.py | 125 +++++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/checker.py b/checker.py index bff3580..ff693e7 100755 --- a/checker.py +++ b/checker.py @@ -11,6 +11,8 @@ from cmd import Cmd import json +# GLOBAL VARIABLES +debug = getenv('DEBUG', False) # Color format for text printing. y = '\033[38;5;220m' # Yellow. g = '\033[92m' # Green. @@ -57,78 +59,79 @@ def preloop(self): def start_up(self): """ Start-up method for getting and storing the user's credentials. """ # Strings for 1st time welcome pre-message. - welcome_l0 = "Hi" - welcome_l1 = "This is the" - welcome_l2 = "CLI-Checker v0.01" - welcome_l3 = "We hope you enjoy" - welcome_l4 = "Please" - welcome_l5 = "Report any issues" - welcome_l6 = "At:" - welcome_l7 = "https://github.com/DiegoCol93/CLI_Checker" - welcome_l8 = "or Follow us in Twitter:" - welcome_l9 = "https://twitter.com/LopezDfelo93" - welcome_l10 = "https://twitter.com/wisvem" - welcome_l11 = "https://twitter.com/leovalsan_dev" - - # Calculate the space around each line's welcome message. - welcome_s0 = ' ' * ((columns // 2) - 1 - len(welcome_l0) // 2) - welcome_s1 = ' ' * ((columns // 2) - 1 - len(welcome_l1) // 2) - welcome_s2 = ' ' * ((columns // 2) - 1 - len(welcome_l2) // 2) - welcome_s3 = ' ' * ((columns // 2) - 1 - len(welcome_l3) // 2) - welcome_s4 = ' ' * ((columns // 2) - 1 - len(welcome_l4) // 2) - welcome_s5 = ' ' * ((columns // 2) - 1 - len(welcome_l5) // 2) - welcome_s6 = ' ' * ((columns // 2) - 1 - len(welcome_l6) // 2) - welcome_s7 = ' ' * ((columns // 2) - 1 - len(welcome_l7) // 2) - welcome_s8 = ' ' * ((columns // 2) - 1 - len(welcome_l8) // 2) - welcome_s9 = ' ' * ((columns // 2) - 1 - len(welcome_l9) // 2) - welcome_s10 = ' ' * ((columns // 2) - 1 - len(welcome_l10) // 2) - welcome_s11 = ' ' * ((columns // 2) - 1 - len(welcome_l11) // 2) - - # Add color for the line 2 after spaces calculation above. - welcome_l2 = "CLI-Checker" + g + " v0.01" + rs - - # Start of printing animation... - # \033[2;0f resets the cursor to line 2 column 0 of the terminal. - print("\033[5;0f", end='') - print("\033[2;0f", end='') - print(welcome_s0 + welcome_l0 + welcome_s0) - sleep(2) + if (debug is False): + welcome_l0 = "Hi" + welcome_l1 = "This is the" + welcome_l2 = "CLI-Checker v0.01" + welcome_l3 = "We hope you enjoy" + welcome_l4 = "Please" + welcome_l5 = "Report any issues" + welcome_l6 = "At:" + welcome_l7 = "https://github.com/DiegoCol93/CLI_Checker" + welcome_l8 = "or Follow us in Twitter:" + welcome_l9 = "https://twitter.com/LopezDfelo93" + welcome_l10 = "https://twitter.com/wisvem" + welcome_l11 = "https://twitter.com/leovalsan_dev" + + # Calculate the space around each line's welcome message. + welcome_s0 = ' ' * ((columns // 2) - 1 - len(welcome_l0) // 2) + welcome_s1 = ' ' * ((columns // 2) - 1 - len(welcome_l1) // 2) + welcome_s2 = ' ' * ((columns // 2) - 1 - len(welcome_l2) // 2) + welcome_s3 = ' ' * ((columns // 2) - 1 - len(welcome_l3) // 2) + welcome_s4 = ' ' * ((columns // 2) - 1 - len(welcome_l4) // 2) + welcome_s5 = ' ' * ((columns // 2) - 1 - len(welcome_l5) // 2) + welcome_s6 = ' ' * ((columns // 2) - 1 - len(welcome_l6) // 2) + welcome_s7 = ' ' * ((columns // 2) - 1 - len(welcome_l7) // 2) + welcome_s8 = ' ' * ((columns // 2) - 1 - len(welcome_l8) // 2) + welcome_s9 = ' ' * ((columns // 2) - 1 - len(welcome_l9) // 2) + welcome_s10 = ' ' * ((columns // 2) - 1 - len(welcome_l10) // 2) + welcome_s11 = ' ' * ((columns // 2) - 1 - len(welcome_l11) // 2) + + # Add color for the line 2 after spaces calculation above. + welcome_l2 = "CLI-Checker" + g + " v0.01" + rs + + # Start of printing animation... + # \033[2;0f resets the cursor to line 2 column 0 of the terminal. + print("\033[5;0f", end='') + print("\033[2;0f", end='') + print(welcome_s0 + welcome_l0 + welcome_s0) + sleep(2) - print(welcome_s1 + welcome_l1 + welcome_s1) - sleep(1.5) + print(welcome_s1 + welcome_l1 + welcome_s1) + sleep(1.5) - print(welcome_s2 + welcome_l2 + welcome_s2) - sleep(1.5) + print(welcome_s2 + welcome_l2 + welcome_s2) + sleep(1.5) - print("\033[2;0f", end='') - print(welcome_s3 + welcome_l3 + welcome_s3) - sleep(1.5) + print("\033[2;0f", end='') + print(welcome_s3 + welcome_l3 + welcome_s3) + sleep(1.5) - print(welcome_s4 + welcome_l4 + welcome_s4) - sleep(1.5) + print(welcome_s4 + welcome_l4 + welcome_s4) + sleep(1.5) - print(welcome_s5 + welcome_l5 + welcome_s5) - sleep(1.5) + print(welcome_s5 + welcome_l5 + welcome_s5) + sleep(1.5) - print("\033[2;0f", end='') - print(welcome_s6 + welcome_l6 + welcome_s6) - sleep(1.5) + print("\033[2;0f", end='') + print(welcome_s6 + welcome_l6 + welcome_s6) + sleep(1.5) - print(welcome_s7 + welcome_l7 + welcome_s7) - sleep(1.5) + print(welcome_s7 + welcome_l7 + welcome_s7) + sleep(1.5) - print(welcome_s8 + welcome_l8 + welcome_s8) - sleep(1.5) + print(welcome_s8 + welcome_l8 + welcome_s8) + sleep(1.5) - print("\033[2;0f", end='') - print(welcome_s9 + welcome_l9 + welcome_s9) - sleep(1.5) + print("\033[2;0f", end='') + print(welcome_s9 + welcome_l9 + welcome_s9) + sleep(1.5) - print(welcome_s10 + welcome_l10 + welcome_s10) - sleep(1.5) + print(welcome_s10 + welcome_l10 + welcome_s10) + sleep(1.5) - print(welcome_s11 + welcome_l11 + welcome_s11) - sleep(1.5) + print(welcome_s11 + welcome_l11 + welcome_s11) + sleep(1.5) # Get user credentials with input box.- - - - - - - - - - - - - - - - | print("\033[5;0f", end='') From 0d7011b82b2dd29142b0a2d29a5d13a47da46353 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 11:52:43 -0500 Subject: [PATCH 07/35] debuging with environments if debug flag is True --- checker.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/checker.py b/checker.py index ff693e7..f93475e 100755 --- a/checker.py +++ b/checker.py @@ -23,6 +23,21 @@ size = get_terminal_size() columns = size.columns +# debug credentials: This information should be in the .env file as +# EMAIL= +# ENABLE=True/False +# API= +# PASSWORD= +debug_cred = { + "enable": debug, + "email": getenv('EMAIL'), + "api": getenv('API'), + "password": getenv('PASSWORD') +} + +if (debug is True): + print(debug_cred) + class CLI_Checker(Cmd): """ Class for controling the main loop of the Checker's Console. """ @@ -140,6 +155,8 @@ def start_up(self): print('└' + '─' * (columns - 2) + '┘') # Variable, somehow... print("\033[6;3f", end='') email = str(input("Please enter your holberton e-mail: ")) + if (debug is True): + email = debug_cred['email'] print("\033[5;0f", end='') print('┌' + '─' * (columns - 2) + '┐') @@ -147,17 +164,17 @@ def start_up(self): print('└' + '─' * (columns - 2) + '┘') print("\033[6;3f", end='') api = str(input("Please enter your API key: ")) + if (debug is True): + api = debug_cred['api'] print("\033[5;0f", end='') print('┌' + '─' * (columns - 2) + '┐') print('│' + ' ' * (columns - 2) + '│') print('└' + '─' * (columns - 2) + '┘') print("\033[6;3f", end='') - if getenv('PSS'): - print('PSS environ variable was found...') - password = getenv('PSS') - else: - password = getpass("\033[6;3fPlease enter your password: ") + password = getpass("\033[6;3fPlease enter your password: ") + if (debug is True): + password = debug_cred['password'] # Load custom mock loading Bar... - - - - - - - - - - - - - - - - - - | i = 0 From 7a7a1ad52595be0684869871e535f29275f85a8a Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 12:00:08 -0500 Subject: [PATCH 08/35] path credentials as variable --- checker.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/checker.py b/checker.py index f93475e..0cb0323 100755 --- a/checker.py +++ b/checker.py @@ -13,6 +13,7 @@ # GLOBAL VARIABLES debug = getenv('DEBUG', False) +PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') # Color format for text printing. y = '\033[38;5;220m' # Yellow. g = '\033[92m' # Green. @@ -56,8 +57,8 @@ class CLI_Checker(Cmd): # Overrides the preloop class method. - - - - - - - - - - - - - - - - - - | def preloop(self): """ Method that runs before the main loop of the console. """ - if path.exists('/tmp/.hbnb_creds'): - with open('/tmp/.hbnb_creds', 'r') as f: + if path.exists(PATH_CREDS): + with open(PATH_CREDS, 'r') as f: creds = json.load(f) email = creds['email'] api = creds['api'] @@ -225,10 +226,10 @@ def start_up(self): print("\033[6;3f", end='') answer = str(input("Please answer Yes or No: ")) - with open('/tmp/.hbnb_creds', 'w+') as f: - cred = 'Your Credentials have been stored in ' \ - '/tmp/.hbnb_creds' if answer in ['yes', 'y']: + with open(PATH_CREDS, 'w+') as f: + cred = 'Your Credentials have been stored in {}' + cred.format(PATH_CREDS) json.dump({'email': email, 'api': api, 'password': password, 'token': ""}, f) print("\033[5;0f", end='') @@ -240,7 +241,7 @@ def start_up(self): print("\033[6;{}f".format((columns - len(cred)) // 2), end='') cred = 'Your Credentials have been stored in ' - print(cred + g + '/tmp/.hbnb_creds' + rs) + print(cred + g + " " + PATH_CREDS + " " + rs) sleep(2) print('') From 7b099adf50805d454eadf675a8c0e0b06ce26384 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 12:40:51 -0500 Subject: [PATCH 09/35] install with repo as variable --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b94e106..ca2dc65 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +REPO="https://github.com/Athesto/CLI_Checker.git" cols=$(tput cols) # ───────────── Get the width of the terminal. cols=$(($cols - 3)) # ─────────── Substract 3 to prevent overflow. @@ -56,7 +57,7 @@ while [ $installed != 1 ]; do echo -en "\033[${size}C" # 2. Clone repository into installation directory. - if sudo git -C /opt/checker clone https://github.com/DiegoCol93/CLI_Checker.git 2> /dev/null; then + if sudo git -C /opt/checker clone ${REPO} 2> /dev/null; then echo -ne '\033[92m' printf '█%.0s' $(seq 0 $size) echo -ne '\033[m' From ca2eac4697274fc7ce1baa8c9977f12a3c97840b Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 12:42:14 -0500 Subject: [PATCH 10/35] debug variable out no more in Global variable, instead use the DEBUG env var --- checker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker.py b/checker.py index 0cb0323..b507537 100755 --- a/checker.py +++ b/checker.py @@ -12,7 +12,6 @@ import json # GLOBAL VARIABLES -debug = getenv('DEBUG', False) PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') # Color format for text printing. y = '\033[38;5;220m' # Yellow. @@ -29,6 +28,7 @@ # ENABLE=True/False # API= # PASSWORD= +debug = bool(getenv('DEBUG', False)) debug_cred = { "enable": debug, "email": getenv('EMAIL'), From 50c5525ca2a35241de3c048d0b1b9849b7a66737 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 12:42:55 -0500 Subject: [PATCH 11/35] include VERSION variable --- checker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/checker.py b/checker.py index b507537..e1f873a 100755 --- a/checker.py +++ b/checker.py @@ -13,6 +13,8 @@ # GLOBAL VARIABLES PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') +VERSION = 'v0.2 (tavo)' + # Color format for text printing. y = '\033[38;5;220m' # Yellow. g = '\033[92m' # Green. @@ -78,7 +80,7 @@ def start_up(self): if (debug is False): welcome_l0 = "Hi" welcome_l1 = "This is the" - welcome_l2 = "CLI-Checker v0.01" + welcome_l2 = "CLI-Checker {}".format(VERSION) welcome_l3 = "We hope you enjoy" welcome_l4 = "Please" welcome_l5 = "Report any issues" @@ -366,7 +368,8 @@ def do_quit(self, arg): CLI_Checker().cmdloop( s + '┌───────────────────────────┐\n' + - s + '│ CLI-Checker ' + g + 'v0.01' + rs + ' │\n' + + s + '│ CLI-Checker │\n' + + s + '│ ' + g + VERSION + rs + ' │\n' + s + '│ by: │\n' + s + '│ 🔥' + y + ' Diego Lopez ' + rs + '🔥 │\n' + s + '│ 🔥' + y + ' Wiston Venera ' + rs + '🔥 │\n' + From 79f0c242abb0162d6e6287c127027878020ba472 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:03:33 -0500 Subject: [PATCH 12/35] remove version in installation script --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index ca2dc65..2dc4414 100755 --- a/install.sh +++ b/install.sh @@ -116,7 +116,7 @@ while [ $installed != 1 ]; do (( installed++ )) echo "" - echo -e "CLI_Checker \033[92mv0.01\033[m has been installed \033[92msuccesfully\033[m." + echo -e "CLI_Checker has been installed \033[92msuccesfully\033[m." echo -e "You may now run:\n" echo -e "\t\033[92mchecker\033[m\n" echo -e "In order to start the checker console." From 273931173d7caf8da34bbd7423555fba632b6563 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:04:56 -0500 Subject: [PATCH 13/35] branch variable --- install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 2dc4414..4bcee64 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash REPO="https://github.com/Athesto/CLI_Checker.git" +BRANCH="main" cols=$(tput cols) # ───────────── Get the width of the terminal. cols=$(($cols - 3)) # ─────────── Substract 3 to prevent overflow. @@ -57,7 +58,7 @@ while [ $installed != 1 ]; do echo -en "\033[${size}C" # 2. Clone repository into installation directory. - if sudo git -C /opt/checker clone ${REPO} 2> /dev/null; then + if sudo git -C /opt/checker clone ${BRANCH} ${REPO} 2> /dev/null; then echo -ne '\033[92m' printf '█%.0s' $(seq 0 $size) echo -ne '\033[m' From 3a7ed51a86caf780c4ff1c7169568de7cfc109af Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:11:16 -0500 Subject: [PATCH 14/35] -b flag in the branch --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 4bcee64..006c05d 100755 --- a/install.sh +++ b/install.sh @@ -58,7 +58,7 @@ while [ $installed != 1 ]; do echo -en "\033[${size}C" # 2. Clone repository into installation directory. - if sudo git -C /opt/checker clone ${BRANCH} ${REPO} 2> /dev/null; then + if sudo git -C /opt/checker clone -b ${BRANCH} ${REPO} 2> /dev/null; then echo -ne '\033[92m' printf '█%.0s' $(seq 0 $size) echo -ne '\033[m' From aac7fcb9846fe6b7541b7bcc8aac5c928ee9324d Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:17:00 -0500 Subject: [PATCH 15/35] branch as global variable --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 006c05d..7716ad3 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash REPO="https://github.com/Athesto/CLI_Checker.git" -BRANCH="main" +BRANCH=${BRANCH-"main"} cols=$(tput cols) # ───────────── Get the width of the terminal. cols=$(($cols - 3)) # ─────────── Substract 3 to prevent overflow. From dd476b161cb0bdeef63e43a21afc9a53f5bdce3e Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:38:35 -0500 Subject: [PATCH 16/35] try makedirs if file doesn't exist --- checker.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/checker.py b/checker.py index e1f873a..f161aff 100755 --- a/checker.py +++ b/checker.py @@ -5,7 +5,7 @@ from modules.get_project import get_tasks from modules.get_auth import get_auth -from os import path, get_terminal_size, getenv +from os import path, get_terminal_size, getenv, makedirs from getpass import getpass from time import sleep from cmd import Cmd @@ -13,6 +13,7 @@ # GLOBAL VARIABLES PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') +PATH_TOKEN = '/tmp/.hbnb_auth_token' VERSION = 'v0.2 (tavo)' # Color format for text printing. @@ -67,10 +68,12 @@ def preloop(self): password = creds['password'] get_auth(email, api, password) else: - if path.exists('/tmp/.hbnb_auth_token'): + if path.exists(PATH_TOKEN): return else: + print('Credentials not found') print('\033[2J', end='') + self.start_up() # 1st time startup method.- - - - - - - - - - - - - - - - - - - - - - - -| @@ -232,6 +235,10 @@ def start_up(self): with open(PATH_CREDS, 'w+') as f: cred = 'Your Credentials have been stored in {}' cred.format(PATH_CREDS) + try: + os.makedirs(path.dirname(PATH_CREDS)) + except FileExistsError as f: + pass json.dump({'email': email, 'api': api, 'password': password, 'token': ""}, f) print("\033[5;0f", end='') From 192b25331d70602f0531c89e149022cc9a9fe3a6 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:44:38 -0500 Subject: [PATCH 17/35] mkdirs without os --- checker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker.py b/checker.py index f161aff..c11e074 100755 --- a/checker.py +++ b/checker.py @@ -236,7 +236,7 @@ def start_up(self): cred = 'Your Credentials have been stored in {}' cred.format(PATH_CREDS) try: - os.makedirs(path.dirname(PATH_CREDS)) + makedirs(path.dirname(PATH_CREDS)) except FileExistsError as f: pass json.dump({'email': email, 'api': api, From 31e7206a1577ca3beae329e9df2a0ca7302bccc4 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 13:54:52 -0500 Subject: [PATCH 18/35] fix try brefore open file --- checker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/checker.py b/checker.py index c11e074..075b569 100755 --- a/checker.py +++ b/checker.py @@ -232,13 +232,13 @@ def start_up(self): answer = str(input("Please answer Yes or No: ")) if answer in ['yes', 'y']: + try: + makedirs(path.dirname(PATH_CREDS)) + except FileExistsError as f: + pass with open(PATH_CREDS, 'w+') as f: cred = 'Your Credentials have been stored in {}' cred.format(PATH_CREDS) - try: - makedirs(path.dirname(PATH_CREDS)) - except FileExistsError as f: - pass json.dump({'email': email, 'api': api, 'password': password, 'token': ""}, f) print("\033[5;0f", end='') From df59f6fd3059d468d8aad90beee1ae15d9cf85a2 Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 14:04:27 -0500 Subject: [PATCH 19/35] documentation --- CHANGELOG.md | 14 ++++++++++++++ README.md | 18 ++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..ce66e8f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog +> here you can see every change between versions + +## v0.2 +### Added + - `.env` file support, It use `EMAIL`, `PASSWORD`, `API`, `DEBUG` variables + - `VERSION`, `PATH_CRED` variables + +### Fix + - Set installation confirmation problem with ['Y'/'N'] + - checker.py with pycodestyle + - move `hbnb_creds`, the `/tmp` folder delete the credentials + + diff --git a/README.md b/README.md index b5ea0d3..6aac883 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ -# ⚡ CLI_Checker ⚡ - > A Holberton School checker tool to avoid using your browser to check manaully every task of your current project. +# ⚡ CLI_Checker (vTavo) ⚡ + > A Holberton School checker tool to avoid using your browser to check manaully every task of your current project.
+ > This is a fork of the original project by Diego Lopez. Please check his [page][CLI_Diego] ## How to install -clone the repo and run the instalation script +Run the instalation script ```console -$ git clone https://github.com/DiegoCol93/CLI_Checker -$ cd CLI_Checker -$ ./install.sh +$ bash <(curl -sL https://github.com/Athesto/CLI_Checker/raw/main/install.sh) $ checker ``` the program are going to ask for: @@ -17,9 +16,6 @@ the program are going to ask for: - it's an HEX string of 32 chars ex. `123abc123abcdef99001122cdef12351` - your intranet's __password__ (it will be hidden so don't worry if you don't see the chars) -after finishing the credentials it will ask for storing credentials - - note: it has problem so write «__yes__» in lowercase - ## How to use just run cecker in your terminal ant the checker terminal will start @@ -80,7 +76,7 @@ Checking your code... 🎉 - [Diego Lopez][@DiegoCol93] - [Wiston Venera][@wsvem] - [Leonardo Valencia][@4ions] -- [Gustavo Mejía][@Athesto] (README) +- [Gustavo Mejía][@Athesto] [api_link]: https://intranet.hbtn.io/dashboards/my_tools @@ -88,3 +84,5 @@ Checking your code... 🎉 [@wsvem]: https://github.com/wisvem [@4ions]: https://github.com/4ions [@DiegoCol93]: https://github.com/DiegoCol93 +[CLI_Diego]: https://github.com/DiegoCol93/CLI_Checker/ + From 7998e882b6c2c6a7a0017461d8fef4c52054677d Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 14:04:52 -0500 Subject: [PATCH 20/35] ignore elements --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 092cf7c..12a557b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ credentials *pyc .env .*.swp +tmp/ From 3e21f42cff1c50af75a6b8847cbb7300fe3b58aa Mon Sep 17 00:00:00 2001 From: Athesto Date: Sun, 18 Jul 2021 14:18:58 -0500 Subject: [PATCH 21/35] uninstalll instructions --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6866bee..42de154 100644 --- a/README.md +++ b/README.md @@ -74,7 +74,16 @@ Checking your code... 🎉 - project: select project - check: slect task - +### How to uninstall +To uninstall you only need to delete these files + - `/opt/checker` + - `/usr/local/bin/checker` + - credentials in `~/.config/hbn` +```console +$ sudo rm -rf /opt/checker/ +$ sudo rm /usr/local/bin/checker +$ rm -rf ~/.config/hbn +``` ## Contributors - [Diego Lopez][@DiegoCol93] - [Wiston Venera][@wsvem] From a88177865a6ac2a45c6dd664a6d5092cd57f15aa Mon Sep 17 00:00:00 2001 From: Athesto Date: Mon, 19 Jul 2021 09:15:01 -0500 Subject: [PATCH 22/35] include VERSION in the long long input message --- checker.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/checker.py b/checker.py index 075b569..f32b7fb 100755 --- a/checker.py +++ b/checker.py @@ -15,7 +15,7 @@ PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') PATH_TOKEN = '/tmp/.hbnb_auth_token' VERSION = 'v0.2 (tavo)' - +REPO = "https://github.com/Athesto/CLI_Checker" # Color format for text printing. y = '\033[38;5;220m' # Yellow. g = '\033[92m' # Green. @@ -88,8 +88,8 @@ def start_up(self): welcome_l4 = "Please" welcome_l5 = "Report any issues" welcome_l6 = "At:" - welcome_l7 = "https://github.com/DiegoCol93/CLI_Checker" - welcome_l8 = "or Follow us in Twitter:" + welcome_l7 = REPO + welcome_l8 = "Follow us in Twitter:" welcome_l9 = "https://twitter.com/LopezDfelo93" welcome_l10 = "https://twitter.com/wisvem" welcome_l11 = "https://twitter.com/leovalsan_dev" @@ -109,7 +109,7 @@ def start_up(self): welcome_s11 = ' ' * ((columns // 2) - 1 - len(welcome_l11) // 2) # Add color for the line 2 after spaces calculation above. - welcome_l2 = "CLI-Checker" + g + " v0.01" + rs + welcome_l2 = "CLI-Checker" + g + " " + VERSION + rs # Start of printing animation... # \033[2;0f resets the cursor to line 2 column 0 of the terminal. From 9ab7554c2ce1ba83be5ace7287ecf150e4655a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustavo=20Adolfo=20Mej=C3=ADa=20S=C3=A1nchez?= Date: Sat, 24 Jul 2021 09:27:29 -0500 Subject: [PATCH 23/35] Add files via upload --- Screenshot from 2021-07-24 09-27-03.png | Bin 0 -> 2323 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Screenshot from 2021-07-24 09-27-03.png diff --git a/Screenshot from 2021-07-24 09-27-03.png b/Screenshot from 2021-07-24 09-27-03.png new file mode 100644 index 0000000000000000000000000000000000000000..71b5e98da36dce0f089ab49857f3ec807ef006b6 GIT binary patch literal 2323 zcmV+u3GDWXP)ZgXgFbngSdJ^%m!CUiwubVG7w zVRUJ4ZXi@?ZDjy+;bI^%G$3kqY#=f)GBF@9IXW^oIx#ab-e}j7BPZTz6gX_nD zSkZ=M%7W2;xO511-T?V&cytxGisBu`T>aFD9C`~ z6@a5h;mfTcCymX9WP4I?UmwBy?#l>`LP7QS_alU$tgI~cSvq(j1d=4B{z{URBaiyk zTcGt7H2Bms2rs?`BblqH4aqc3bX~_VjMN^_yz_Z_8>cT>mXT%oE`%H}0K+ga3?oPA z{o~(YOm%fDP$w>fnhXWogKPkXVPIJnilR_kQ-h*7UnM6}MMVX`r1P9%7>tgNl1LX3HCwV8nm_FBk{;0j0GybS6)Urf6)P`cL9Ce>Sh>53e;3qx?-g$3WoJT z0b3YHYCwB%6Qe&~4z3>Df8L9H=uL>n3+g31>~vk9(36IShB$EG0Fg+9L?VIT?`PSv zWwf-kWK7iA>hA6)91gQ&$r36nD<`!lcHwBLH^tSMRm~VPC6wMPlpTK!apj8R`7S-= z(m~m)Pqw^XFRiVuG&D3|Sr*HeFQ>7wand>L_U+qrb#7jXitz zFfcGcTU#4z*RJK`~&3LFuq^(f@(t94B~VBlwCW3_~}8%-PxdIS#}Hwl8L0p;~@|TP+ne6 zO-&6qZ{9@HG=jk()z#G~io)RFAONdZucoW3iyb?5aO~Kzao&_PMxtTitWtPX6=u_R z;(NbOe7=I*Wa4|~2*HOmSn7sX{t1!Si|Sd|b;icV@OV6qR=i*^h^nfD!(m)57ehls zG&D3&R#rxLcQ-vfJ*jrlXq3**PTJbqsIRYQ_wLr85zMa417Lc&XbqQ%1Y|$>IepdtXQ#vGiT0l z>eMMVZQ4X25MblRjqKaEkBW*4T3cK3`~AqWOnrSl$B!RRev{f-8XFrY>|b&(&9T=D zh2XvSCiyyZFj}{uKKC8s3nj30r_=$;q`hk3}fODDL{6r;WRJ1b?a8KbJT3iRZkN8bvvBAiiL^Pa|!P+pDP-YE!%iW zl8|H>MV3>k!p9+dQ7JO?=3zX%5`9h?Zb=~DxQOqmXK)`qJtd=r5Re8+mLyDBMp2ZK z6zqzTU5d%!Q44cl0^ln0zN3_%Q_vqC#sB0_rVI)02a*R4b`8kh(!!0Y7R7)OvU{tnN!S8@Ad$p5)k0<)U13$BtRVVWkAB&EDb(=`o&=>A>+E`zou*6->g%6_7o*wyc5j z%!*@rI$;0ra=Gw$JXnBrCkzYqC_67pKZQw$W<#{clocfhs9BY;^AGT|uTj|9T`^MN z8{dWI1t8shsfkvgqsUqq@3!!gfy8-`|gEn&Y=e>7d92mp?stb0>V|He5IiL<=%za+SlJ z74X6~_~N_?TV&5ymSrLACp?8Bo-E6#+6aa^ma~mW8j!LhKd8DO{PpLsb1s}e2;mN< z?p+F0%!UWo!sCy@BM*R*dr7c?qytMob1Ozd2m&)?JpSB$Bz-FR4kkNNw-p_RLvO>0 z<8bC3=!*cIK<+0pUQOVxg5@D-UjrN3VR2mn_a{|~BlT!BisBu{`rwaPLLApxu)5K^ritHK2I|-mKqBZ~k002ovPDHLkV1iR!LIVH* literal 0 HcmV?d00001 From 25ab922fd85b7503ddec50157a894f8fadbc428e Mon Sep 17 00:00:00 2001 From: Athesto Date: Sat, 24 Jul 2021 09:50:02 -0500 Subject: [PATCH 24/35] include images --- README.md | 11 +++++++++-- assets/tool_icon.png | Bin 0 -> 2323 bytes assets/tool_icon2.png | Bin 0 -> 4965 bytes 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 assets/tool_icon.png create mode 100644 assets/tool_icon2.png diff --git a/README.md b/README.md index 42de154..231723b 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,13 @@ > This is a fork of the original project by Diego Lopez. Please check his [page][CLI_Diego] ## Prerquisites -You need the [tools][api_link] section available in the intranet - +You need the [tools][api_link] section available in the intranet. You can check +if you have this icon in the left menu: + +
+ +
+ ## How to install Run the instalation script @@ -97,4 +102,6 @@ $ rm -rf ~/.config/hbn [@4ions]: https://github.com/4ions [@DiegoCol93]: https://github.com/DiegoCol93 [CLI_Diego]: https://github.com/DiegoCol93/CLI_Checker/ +[tool_icon2]: https://github.com/Athesto/CLI_Checker/raw/main/assets/tool_icon2.png +[tool_icon3]: /assets/tool_icon2.png diff --git a/assets/tool_icon.png b/assets/tool_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..71b5e98da36dce0f089ab49857f3ec807ef006b6 GIT binary patch literal 2323 zcmV+u3GDWXP)ZgXgFbngSdJ^%m!CUiwubVG7w zVRUJ4ZXi@?ZDjy+;bI^%G$3kqY#=f)GBF@9IXW^oIx#ab-e}j7BPZTz6gX_nD zSkZ=M%7W2;xO511-T?V&cytxGisBu`T>aFD9C`~ z6@a5h;mfTcCymX9WP4I?UmwBy?#l>`LP7QS_alU$tgI~cSvq(j1d=4B{z{URBaiyk zTcGt7H2Bms2rs?`BblqH4aqc3bX~_VjMN^_yz_Z_8>cT>mXT%oE`%H}0K+ga3?oPA z{o~(YOm%fDP$w>fnhXWogKPkXVPIJnilR_kQ-h*7UnM6}MMVX`r1P9%7>tgNl1LX3HCwV8nm_FBk{;0j0GybS6)Urf6)P`cL9Ce>Sh>53e;3qx?-g$3WoJT z0b3YHYCwB%6Qe&~4z3>Df8L9H=uL>n3+g31>~vk9(36IShB$EG0Fg+9L?VIT?`PSv zWwf-kWK7iA>hA6)91gQ&$r36nD<`!lcHwBLH^tSMRm~VPC6wMPlpTK!apj8R`7S-= z(m~m)Pqw^XFRiVuG&D3|Sr*HeFQ>7wand>L_U+qrb#7jXitz zFfcGcTU#4z*RJK`~&3LFuq^(f@(t94B~VBlwCW3_~}8%-PxdIS#}Hwl8L0p;~@|TP+ne6 zO-&6qZ{9@HG=jk()z#G~io)RFAONdZucoW3iyb?5aO~Kzao&_PMxtTitWtPX6=u_R z;(NbOe7=I*Wa4|~2*HOmSn7sX{t1!Si|Sd|b;icV@OV6qR=i*^h^nfD!(m)57ehls zG&D3&R#rxLcQ-vfJ*jrlXq3**PTJbqsIRYQ_wLr85zMa417Lc&XbqQ%1Y|$>IepdtXQ#vGiT0l z>eMMVZQ4X25MblRjqKaEkBW*4T3cK3`~AqWOnrSl$B!RRev{f-8XFrY>|b&(&9T=D zh2XvSCiyyZFj}{uKKC8s3nj30r_=$;q`hk3}fODDL{6r;WRJ1b?a8KbJT3iRZkN8bvvBAiiL^Pa|!P+pDP-YE!%iW zl8|H>MV3>k!p9+dQ7JO?=3zX%5`9h?Zb=~DxQOqmXK)`qJtd=r5Re8+mLyDBMp2ZK z6zqzTU5d%!Q44cl0^ln0zN3_%Q_vqC#sB0_rVI)02a*R4b`8kh(!!0Y7R7)OvU{tnN!S8@Ad$p5)k0<)U13$BtRVVWkAB&EDb(=`o&=>A>+E`zou*6->g%6_7o*wyc5j z%!*@rI$;0ra=Gw$JXnBrCkzYqC_67pKZQw$W<#{clocfhs9BY;^AGT|uTj|9T`^MN z8{dWI1t8shsfkvgqsUqq@3!!gfy8-`|gEn&Y=e>7d92mp?stb0>V|He5IiL<=%za+SlJ z74X6~_~N_?TV&5ymSrLACp?8Bo-E6#+6aa^ma~mW8j!LhKd8DO{PpLsb1s}e2;mN< z?p+F0%!UWo!sCy@BM*R*dr7c?qytMob1Ozd2m&)?JpSB$Bz-FR4kkNNw-p_RLvO>0 z<8bC3=!*cIK<+0pUQOVxg5@D-UjrN3VR2mn_a{|~BlT!BisBu{`rwaPLLApxu)5K^ritHK2I|-mKqBZ~k002ovPDHLkV1iR!LIVH* literal 0 HcmV?d00001 diff --git a/assets/tool_icon2.png b/assets/tool_icon2.png new file mode 100644 index 0000000000000000000000000000000000000000..ebe66144e444de0f1384cc036b664a89d60a9630 GIT binary patch literal 4965 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 literal 0 HcmV?d00001 From f462be071990ba297798c30750d94ff96da4448e Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 16:57:44 -0500 Subject: [PATCH 25/35] EOL with a line --- checker.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/checker.py b/checker.py index f32b7fb..593bc0b 100755 --- a/checker.py +++ b/checker.py @@ -354,7 +354,8 @@ def do_check(self, arg): show_result(correction_id, self.task_dict, arg) def do_EOF(self, arg): - """ Exits console when receiving an EOF. """ + """ Exits console when receiving an EOF (Ctrl-D)""" + print("goodbye") return True def emptyline(self): From cb1fe02731f6ad5ab5ddb9815871f047b88abaf9 Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 17:49:13 -0500 Subject: [PATCH 26/35] handle SIGINT (Ctrl-c), nop in project, stop check --- checker.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/checker.py b/checker.py index 593bc0b..4057fdf 100755 --- a/checker.py +++ b/checker.py @@ -10,6 +10,7 @@ from time import sleep from cmd import Cmd import json +import signal # manage Ctrl-C # GLOBAL VARIABLES PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') @@ -56,6 +57,16 @@ class CLI_Checker(Cmd): # Help custom instance variables. doc_header = "🤔 Currently availbale commands are: 🤔" ruler = y + "─" + rs + original_handler_ctrl_c = signal.getsignal(signal.SIGINT) + + def __init__(self): + super().__init__() + signal.signal(signal.SIGINT, handler=self._ctrl_c_ignored) + + def _ctrl_c_ignored(self, signal, frame): + '''Ignore SIGINT signal''' + print('^C') + print(self.prompt, end='', flush=True) # Overrides the preloop class method. - - - - - - - - - - - - - - - - - - | def preloop(self): @@ -350,8 +361,14 @@ def do_check(self, arg): print('There is no task # {}'.format(arg)) return - correction_id = request_correction(self.task_dict[arg][1]) - show_result(correction_id, self.task_dict, arg) + try: + signal.signal(signal.SIGINT, handler=self.original_handler_ctrl_c) + correction_id = request_correction(self.task_dict[arg][1]) + show_result(correction_id, self.task_dict, arg) + except: + print("\n\nstop") + finally: + signal.signal(signal.SIGINT, handler=self._ctrl_c_ignore) def do_EOF(self, arg): """ Exits console when receiving an EOF (Ctrl-D)""" From a193bff622b3c9784487ed26defcf184ec7e4cfe Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 18:00:06 -0500 Subject: [PATCH 27/35] fix function name handled ctrl-c --- checker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/checker.py b/checker.py index 4057fdf..ad448e9 100755 --- a/checker.py +++ b/checker.py @@ -15,7 +15,7 @@ # GLOBAL VARIABLES PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') PATH_TOKEN = '/tmp/.hbnb_auth_token' -VERSION = 'v0.2 (tavo)' +VERSION = 'v0.3 (tavo)' REPO = "https://github.com/Athesto/CLI_Checker" # Color format for text printing. y = '\033[38;5;220m' # Yellow. @@ -368,7 +368,7 @@ def do_check(self, arg): except: print("\n\nstop") finally: - signal.signal(signal.SIGINT, handler=self._ctrl_c_ignore) + signal.signal(signal.SIGINT, handler=self._ctrl_c_ignored) def do_EOF(self, arg): """ Exits console when receiving an EOF (Ctrl-D)""" From 5c93a24b9c22405d1af137e6c6bf98833fa051b9 Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 18:00:13 -0500 Subject: [PATCH 28/35] makefile --- makefile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 makefile diff --git a/makefile b/makefile new file mode 100644 index 0000000..02ae66e --- /dev/null +++ b/makefile @@ -0,0 +1,6 @@ +install: + bash <(curl -sL https://github.com/Athesto/CLI_Checker/raw/main/install.sh) + +uninstall: + sudo rm -rf /opt/checker/ + sudo rm /usr/local/bin/checker From d7be69cdbc61396457f2141d33a0a54945435792 Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 18:00:24 -0500 Subject: [PATCH 29/35] v0.3 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce66e8f..c3bf886 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ # Changelog > here you can see every change between versions +## v0.3 +### Added + - Handle Ctrl-c in checker + - `makefile` with `install` and `uninstall` + - `EOL` with a goodbye message + ## v0.2 ### Added - `.env` file support, It use `EMAIL`, `PASSWORD`, `API`, `DEBUG` variables From 134d0e84bf21387f5f78a24dbda7f95e43d9ea2f Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 18:05:30 -0500 Subject: [PATCH 30/35] SHELL bash in makefile --- makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/makefile b/makefile index 02ae66e..6a4f39a 100644 --- a/makefile +++ b/makefile @@ -1,3 +1,5 @@ +SHELL:=/bin/bash + install: bash <(curl -sL https://github.com/Athesto/CLI_Checker/raw/main/install.sh) From 551b1453a6edb458822ba628e69c51dcc903e406 Mon Sep 17 00:00:00 2001 From: Athesto Date: Tue, 27 Jul 2021 18:08:24 -0500 Subject: [PATCH 31/35] remove uknown image --- Screenshot from 2021-07-24 09-27-03.png | Bin 2323 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 Screenshot from 2021-07-24 09-27-03.png diff --git a/Screenshot from 2021-07-24 09-27-03.png b/Screenshot from 2021-07-24 09-27-03.png deleted file mode 100644 index 71b5e98da36dce0f089ab49857f3ec807ef006b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2323 zcmV+u3GDWXP)ZgXgFbngSdJ^%m!CUiwubVG7w zVRUJ4ZXi@?ZDjy+;bI^%G$3kqY#=f)GBF@9IXW^oIx#ab-e}j7BPZTz6gX_nD zSkZ=M%7W2;xO511-T?V&cytxGisBu`T>aFD9C`~ z6@a5h;mfTcCymX9WP4I?UmwBy?#l>`LP7QS_alU$tgI~cSvq(j1d=4B{z{URBaiyk zTcGt7H2Bms2rs?`BblqH4aqc3bX~_VjMN^_yz_Z_8>cT>mXT%oE`%H}0K+ga3?oPA z{o~(YOm%fDP$w>fnhXWogKPkXVPIJnilR_kQ-h*7UnM6}MMVX`r1P9%7>tgNl1LX3HCwV8nm_FBk{;0j0GybS6)Urf6)P`cL9Ce>Sh>53e;3qx?-g$3WoJT z0b3YHYCwB%6Qe&~4z3>Df8L9H=uL>n3+g31>~vk9(36IShB$EG0Fg+9L?VIT?`PSv zWwf-kWK7iA>hA6)91gQ&$r36nD<`!lcHwBLH^tSMRm~VPC6wMPlpTK!apj8R`7S-= z(m~m)Pqw^XFRiVuG&D3|Sr*HeFQ>7wand>L_U+qrb#7jXitz zFfcGcTU#4z*RJK`~&3LFuq^(f@(t94B~VBlwCW3_~}8%-PxdIS#}Hwl8L0p;~@|TP+ne6 zO-&6qZ{9@HG=jk()z#G~io)RFAONdZucoW3iyb?5aO~Kzao&_PMxtTitWtPX6=u_R z;(NbOe7=I*Wa4|~2*HOmSn7sX{t1!Si|Sd|b;icV@OV6qR=i*^h^nfD!(m)57ehls zG&D3&R#rxLcQ-vfJ*jrlXq3**PTJbqsIRYQ_wLr85zMa417Lc&XbqQ%1Y|$>IepdtXQ#vGiT0l z>eMMVZQ4X25MblRjqKaEkBW*4T3cK3`~AqWOnrSl$B!RRev{f-8XFrY>|b&(&9T=D zh2XvSCiyyZFj}{uKKC8s3nj30r_=$;q`hk3}fODDL{6r;WRJ1b?a8KbJT3iRZkN8bvvBAiiL^Pa|!P+pDP-YE!%iW zl8|H>MV3>k!p9+dQ7JO?=3zX%5`9h?Zb=~DxQOqmXK)`qJtd=r5Re8+mLyDBMp2ZK z6zqzTU5d%!Q44cl0^ln0zN3_%Q_vqC#sB0_rVI)02a*R4b`8kh(!!0Y7R7)OvU{tnN!S8@Ad$p5)k0<)U13$BtRVVWkAB&EDb(=`o&=>A>+E`zou*6->g%6_7o*wyc5j z%!*@rI$;0ra=Gw$JXnBrCkzYqC_67pKZQw$W<#{clocfhs9BY;^AGT|uTj|9T`^MN z8{dWI1t8shsfkvgqsUqq@3!!gfy8-`|gEn&Y=e>7d92mp?stb0>V|He5IiL<=%za+SlJ z74X6~_~N_?TV&5ymSrLACp?8Bo-E6#+6aa^ma~mW8j!LhKd8DO{PpLsb1s}e2;mN< z?p+F0%!UWo!sCy@BM*R*dr7c?qytMob1Ozd2m&)?JpSB$Bz-FR4kkNNw-p_RLvO>0 z<8bC3=!*cIK<+0pUQOVxg5@D-UjrN3VR2mn_a{|~BlT!BisBu{`rwaPLLApxu)5K^ritHK2I|-mKqBZ~k002ovPDHLkV1iR!LIVH* From 9e15d8390b2cf4f6e966f0cd1c236bc7524017ad Mon Sep 17 00:00:00 2001 From: Athesto Date: Mon, 2 Aug 2021 15:28:19 -0500 Subject: [PATCH 32/35] initialize v0.4 --- checker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker.py b/checker.py index ad448e9..555a25d 100755 --- a/checker.py +++ b/checker.py @@ -15,7 +15,7 @@ # GLOBAL VARIABLES PATH_CREDS = path.expanduser('~/.config/hbn/hbnb_creds') PATH_TOKEN = '/tmp/.hbnb_auth_token' -VERSION = 'v0.3 (tavo)' +VERSION = 'v0.4 (tavo)' REPO = "https://github.com/Athesto/CLI_Checker" # Color format for text printing. y = '\033[38;5;220m' # Yellow. From c91ff225705dc79e64881a2a0a62a3ea3a7ad7e7 Mon Sep 17 00:00:00 2001 From: Athesto Date: Mon, 2 Aug 2021 15:28:53 -0500 Subject: [PATCH 33/35] manage signals for ptyhon3.4 --- CHANGELOG.md | 4 ++++ checker.py | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3bf886..af4ce28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog > here you can see every change between versions +## v0.4 +### Fixed + - python3.4 had problems with singal.signal() + ## v0.3 ### Added - Handle Ctrl-c in checker diff --git a/checker.py b/checker.py index 555a25d..6567c8e 100755 --- a/checker.py +++ b/checker.py @@ -61,7 +61,7 @@ class CLI_Checker(Cmd): def __init__(self): super().__init__() - signal.signal(signal.SIGINT, handler=self._ctrl_c_ignored) + signal.signal(signal.SIGINT, self._ctrl_c_ignored) def _ctrl_c_ignored(self, signal, frame): '''Ignore SIGINT signal''' @@ -362,13 +362,13 @@ def do_check(self, arg): return try: - signal.signal(signal.SIGINT, handler=self.original_handler_ctrl_c) + signal.signal(signal.SIGINT, self.original_handler_ctrl_c) correction_id = request_correction(self.task_dict[arg][1]) show_result(correction_id, self.task_dict, arg) except: print("\n\nstop") finally: - signal.signal(signal.SIGINT, handler=self._ctrl_c_ignored) + signal.signal(signal.SIGINT, self._ctrl_c_ignored) def do_EOF(self, arg): """ Exits console when receiving an EOF (Ctrl-D)""" From 792d521b6fe45bf0be9f49d7279431451ae5b285 Mon Sep 17 00:00:00 2001 From: Athesto Date: Mon, 2 Aug 2021 15:32:25 -0500 Subject: [PATCH 34/35] manage project if it doesn't have any argument --- CHANGELOG.md | 1 + modules/get_project.py | 75 +++++++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af4ce28..cba4a4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ## v0.4 ### Fixed - python3.4 had problems with singal.signal() + - manage project if there is no arguments ## v0.3 ### Added diff --git a/modules/get_project.py b/modules/get_project.py index 2572941..8037955 100755 --- a/modules/get_project.py +++ b/modules/get_project.py @@ -4,49 +4,64 @@ from os import environ, path from sys import argv as av from requests import get -from json import dump +from json import dump, load + +PATH_CURRENT_PROJECT = '/tmp/.hbnb_current_project' + def get_tasks(project_number): """ Prints all of the ids of the tasks in the given project. """ - if path.exists('/tmp/.hbnb_auth_token') is None: - print("No /tmp/.hbnb_auth_token file...") - return + bad_emoji = ['🤢', '🤕', '🤮', '🥵', '🤒', '😵', '🤯', '🥶', '🩹'] - with open('/tmp/.hbnb_auth_token', 'r') as f: - auth = f.read() + if (project_number != ""): + if path.exists('/tmp/.hbnb_auth_token') is False: + print("No /tmp/.hbnb_auth_token file...") + return - url = "https://intranet.hbtn.io/projects/{}.json?auth_token={}" \ - .format(project_number, auth) + with open('/tmp/.hbnb_auth_token', 'r') as f: + auth = f.read() - response = get(url) + url = "https://intranet.hbtn.io/projects/{}.json?auth_token={}" \ + .format(project_number, auth) - bad_emoji = ['🤢', '🤕', '🤮', '🥵', '🤒', '😵', '🤯', '🥶', '🩹'] + response = get(url) - if response.status_code == 200: - try: - tasks = response.json()['tasks'] - except: - print('{} This project is not available for you yet sorry. {}' - .format(bad_emoji[rand(0,8)], bad_emoji[rand(0,8)])) + if response.status_code == 200: + try: + tasks = response.json()['tasks'] + except: + print('{} This project is not available for you yet sorry. {}' + .format(bad_emoji[rand(0, 8)], bad_emoji[rand(0, 8)])) + return + else: + # Error no project found. + print('{} The project # \033[91m{}\033[m was \033[91m{}\033[m {}' + .format(bad_emoji[rand(0, 8)], project_number, + response.json()['error'], bad_emoji[rand(0, 8)])) return + + number = 0 + tasks_dict = {} + for task in tasks: + title = task['title'] + task_id = task['id'] + tasks_dict[str(number)] = [title, task_id] + number += 1 else: - # Error no project found. - print('{} The project # \033[91m{}\033[m was \033[91m{}\033[m {}' - .format(bad_emoji[rand(0,8)], project_number, - response.json()['error'], bad_emoji[rand(0,8)])) - return - - number = 0 - tasks_dict = {} - for task in tasks: - title = task['title'] - task_id = task['id'] + if path.exists(PATH_CURRENT_PROJECT) is True: + with open(PATH_CURRENT_PROJECT, 'r') as f: + tasks_dict = load(f) + else: + print('{} Project not found'.format(bad_emoji[rand(0, 8)])) + return + + for key, value in tasks_dict.items(): + number = key + [title, task_id] = value print('\033[92m{}\033[m - {}'.format(number, title)) - tasks_dict[str(number)] = [title, task_id] - number += 1 - with open('/tmp/.hbnb_current_project', 'w') as f: + with open(PATH_CURRENT_PROJECT, 'w') as f: dump(tasks_dict, f) return(tasks_dict) From 76e5e82182ae8e65326c408c1143e741adc32c5c Mon Sep 17 00:00:00 2001 From: Athesto Date: Mon, 2 Aug 2021 15:49:27 -0500 Subject: [PATCH 35/35] sort tasks --- modules/get_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/get_project.py b/modules/get_project.py index 8037955..0c70b4e 100755 --- a/modules/get_project.py +++ b/modules/get_project.py @@ -56,7 +56,7 @@ def get_tasks(project_number): print('{} Project not found'.format(bad_emoji[rand(0, 8)])) return - for key, value in tasks_dict.items(): + for key, value in sorted(tasks_dict.items()): number = key [title, task_id] = value print('\033[92m{}\033[m - {}'.format(number, title))