diff options
author | Alexander Hayden <alexhayden25@gmail.com> | 2019-02-02 10:37:40 -0500 |
---|---|---|
committer | Alexander Hayden <alexhayden25@gmail.com> | 2019-02-02 10:37:40 -0500 |
commit | 0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a (patch) | |
tree | aa5872cf92773b6c949a9b2efa52564eb2f4d1a1 /update.py | |
parent | 81d427007544de048ce684ac69b86959ef7e6a6f (diff) | |
download | modpackman-0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a.tar.gz modpackman-0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a.zip |
C L A R I F Y T H E W O R D S
Diffstat (limited to 'update.py')
-rwxr-xr-x | update.py | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -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: <jarname> <hex digested sha1> <direct download url>\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]} <apply_updates|find_updates>") - 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]} <install|apply_updates|check_updates>") + 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]} <install|apply_updates|check_updates>") sys.exit(-1) |