diff --git a/actions.py b/actions.py index 1b3e2fb..8a9dbef 100644 --- a/actions.py +++ b/actions.py @@ -187,6 +187,25 @@ def download(imageType, parsed_respObj): quit() return saveNameList +def installReqs(): + if is_pip_installed == True: + # open Requirements.txt + # subprocess.call(["pip", "install", module], stdout=subprocess.DEVNULL, + # stdin =subprocess.DEVNULL, + # stderr=subprocess.DEVNULL) + else: + print("You need to install pip.") + +def is_pip_installed(): + try: + subprocess.call(["pip", "--version"], stdout=subprocess.DEVNULL, + stdin =subprocess.DEVNULL, + stderr=subprocess.DEVNULL) + except FileNotFoundError: + return False + else: + return True + # The following code is from Red-DiscordBot # https://github.com/Cog-Creators/Red-DiscordBot def is_git_installed(): diff --git a/checks.py b/checks.py index b81788a..2639144 100644 --- a/checks.py +++ b/checks.py @@ -1,4 +1,5 @@ import json + import requests import datetime diff --git a/launcher.py b/launcher.py index 812ff84..e4b8625 100644 --- a/launcher.py +++ b/launcher.py @@ -4,15 +4,13 @@ from login import login from actions import wait from actions import clear_screen from actions import clearFolders +from actions import installReqs from actions import refreshToken from actions import update from search import search # TODO fix naming convention for all variables and functions -def user_choice(): - return input("> ").lower().strip() - while True: clear_screen() print("=============================\n" @@ -22,12 +20,11 @@ while True: print("1. Search theTVDB.com") print("2. Clear download folders") print("3. Login/Change login") - # print("4. Refresh API Token") print("4. Install Requirements") print("5. Check for updates\n") print("0. Exit\n") - choice = user_choice() + choice = input("> ").lower().strip() if choice == "1": search() @@ -36,12 +33,12 @@ while True: clear_screen() clearFolders() wait() - elif choice == "3": # TODO if already logged in, ask 'are you sure?' + elif choice == "3": # TODO add a printout that tells the user who is currently logged in clear_screen() login() wait() elif choice == "4": - print("install requirements not implemented yet") + installReqs() wait() elif choice == "5": update() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b267c17 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +python-dateutil==2.6.1 +requests==2.18.4 +urllib3==1.22 diff --git a/search.py b/search.py index cce9279..3359be6 100644 --- a/search.py +++ b/search.py @@ -2,9 +2,9 @@ import os.path import json import datetime +import dateutil import requests import urllib.parse -import dateutil from actions import clearFolders from actions import clear_screen