Did some work on update()

This commit is contained in:
Clayton Wilson 2017-11-03 12:56:25 -04:00
parent 9507bcc26c
commit 9bcebbce48
4 changed files with 30 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,4 +2,3 @@
login.json login.json
api info.txt api info.txt
__pycache__ __pycache__
menuLayout.txt

View File

@ -4,6 +4,7 @@ import json
import datetime import datetime
import dateutil import dateutil
import os import os
import subprocess
from checks import checkTimestamp from checks import checkTimestamp
from checks import getToken from checks import getToken
@ -62,7 +63,7 @@ def clearLogin():
except Exception as e: except Exception as e:
pass pass
def clearFolders():# TODO implement this def clearFolders(): # TODO implement this
folders = ["banner", "fanart", "poster"] folders = ["banner", "fanart", "poster"]
for folder in folders: for folder in folders:
if os.path.exists(folder): if os.path.exists(folder):
@ -127,3 +128,29 @@ def download(imageType, parsed_respObj):
else: else:
quit() quit()
return saveNameList return saveNameList
# The following code is from Red-DiscordBot
# https://github.com/Cog-Creators/Red-DiscordBot
def is_git_installed():
try:
subprocess.call(["git", "--version"], stdout=subprocess.DEVNULL,
stdin =subprocess.DEVNULL,
stderr=subprocess.DEVNULL)
except FileNotFoundError:
return False
else:
return True
def update():
try:
code = subprocess.call(("git", "pull", "--ff-only"))
except FileNotFoundError:
print("\nError: Git not found. It's either not installed or you did "
"not clone this using git. Install instructions are on the GitHub: "
"https://github.com/ClaytonWWilson/Image-fetcher-for-theTVDB.com")
return
if code == 0:
print("\nProgram has been updated.")
else:
print("\nThere was an error while updating. This may be caused by edits "
"you have made to the code.")

View File

@ -45,7 +45,7 @@ while True:
print("install requirements") print("install requirements")
break break
elif choice == "6": elif choice == "6":
print("update") update()
break wait()
elif choice == "0": elif choice == "0":
exit() exit()

View File

@ -1,3 +0,0 @@
from login import login
login()