From 0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a Mon Sep 17 00:00:00 2001 From: Alexander Hayden Date: Sat, 2 Feb 2019 10:37:40 -0500 Subject: C L A R I F Y T H E W O R D S --- update.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'update.py') diff --git a/update.py b/update.py index ce45c13..c62b02f 100755 --- a/update.py +++ b/update.py @@ -33,26 +33,27 @@ def install(): os.remove(os.path.join(INSTALL_DIR, jar)) print(f"Removing '{jar}'") - print("\nFinished updating pack!") + print("\nFinished installing mods!") # Using the latest urls, update downloads.txt to match the urls and have the correct sha1 def apply_updates(): - print("Reading update file...") + print("Populating downloads.txt...") mods = read_file("latest-urls.txt") - print("Downloading new versions of all mods...") + print("Getting new versions of all mods...") with open('downloads.txt', 'w') as f: f.write('# Format: \n') for mod in mods: - print(f"Downloading {mod[0]}...") + print(f"Fetching {mod[0]}...") resp = requests.get(mod[1]) hsh = hashlib.sha1(resp.content) f.write(f'{mod[0]} {hsh.hexdigest()} {resp.url}\n') - print("\nDone downloading updates!") + print("\nDone!\nUpdates applied to downloads.txt") + print("[!] No mods were installed. To update your mods folder, run 'update.py install'") # Find if any updates are available def check_updates(): - print("Reading update files...") + print("check_updates: Checking for updates to mods...") latest = read_file("latest-urls.txt") old = read_file("downloads.txt") old_urls = [mod[2] for mod in old] @@ -78,14 +79,19 @@ def read_file(fil): if len(sys.argv) < 2: - print(f"Usage: {sys.argv[0]} ") - sys.exit(-1) + #install by default + install() elif sys.argv[1] == 'install': install() elif sys.argv[1] == 'apply_updates': apply_updates() elif sys.argv[1] == 'check_updates': check_updates() +elif 'h' in sys.argv[1]: + print(f"Usage: {sys.argv[0]} ") + print(" install\tdownloads mods listed in downloads.txt and populates the mods folder specified in pack-location.txt") + print(" apply_updates\tusing the latest downloads in latest-urls.txt, repopulates downloads.txt to reflect the most recent mod versions") + print(" check_updates\tcompares downloads.txt and latest-urls.txt to see if any mods can be updated") else: print(f"Usage: {sys.argv[0]} ") sys.exit(-1) -- cgit v1.2.3