aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Hayden <alexhayden25@gmail.com>2019-02-02 10:37:40 -0500
committerAlexander Hayden <alexhayden25@gmail.com>2019-02-02 10:37:40 -0500
commit0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a (patch)
treeaa5872cf92773b6c949a9b2efa52564eb2f4d1a1
parent81d427007544de048ce684ac69b86959ef7e6a6f (diff)
downloadmodpackman-0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a.tar.gz
modpackman-0d5c8a8d21eb6e2cd4bd9ebd8fd53aef13cfb52a.zip
C L A R I F Y T H E W O R D S
-rw-r--r--readme.md5
-rwxr-xr-xupdate.py22
2 files changed, 19 insertions, 8 deletions
diff --git a/readme.md b/readme.md
index 51228c9..3cb9ccd 100644
--- a/readme.md
+++ b/readme.md
@@ -8,3 +8,8 @@ Script to update modpacks automatically
Simply put the location of your `mods` folder in `pack-location.txt` and run `python update.py install`
Requires the `requests` module.
+
+#### Maintenance:
+
+To check `downloads.txt` modlist for updates against `latest-urls.txt` modlist, run `python update.py check_updates`
+To automatically populate `downloads.txt` with the most recent versions of mods listed in `latest-urls.txt` run `python update.py apply_updates`
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: <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)