aboutsummaryrefslogtreecommitdiff
path: root/update.py
diff options
context:
space:
mode:
authorDylan Jones <dylanjones2011@gmail.com>2019-01-29 21:06:02 -0500
committerDylan Jones <dylanjones2011@gmail.com>2019-01-29 21:06:02 -0500
commit191c477916477477bc3dd7b776fc0216c3970d7f (patch)
tree16b182dcefa0896f872e7813ef3b567e64e2e7c0 /update.py
parentef95964d175e7dc62dec58c9b4612ad446518f42 (diff)
downloadmodpackman-191c477916477477bc3dd7b776fc0216c3970d7f.tar.gz
modpackman-191c477916477477bc3dd7b776fc0216c3970d7f.zip
make it work more
Diffstat (limited to 'update.py')
-rwxr-xr-xupdate.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/update.py b/update.py
index 845937e..5e23f37 100755
--- a/update.py
+++ b/update.py
@@ -11,6 +11,7 @@ with open("pack-location.txt", "r") as f:
INSTALL_DIR = f.read().strip()
+# Apply updates to the actual mod pack
def apply_updates():
print("Updating pack...")
# (fname, url)
@@ -20,12 +21,12 @@ def apply_updates():
with open("downloads.txt", "r") as f:
for line in f:
- dl = line.strip().split(" ")
+ mod = line.strip().split(" ")
if len(line) >= 1 and line[0] != '#':
# run strip on each element
mod = tuple(map(lambda x: x.strip(), mod))
- mods.append(dl)
- names.add(dl[0])
+ mods.append(mod)
+ names.add(mod[0])
for mod in mods:
if mod[0] in os.listdir(INSTALL_DIR) and hashlib.sha1(open(os.path.join(INSTALL_DIR, mod[0]), 'rb').read()).hexdigest() == mod[1]:
print("Skipping " + mod[0] + ", already up to date")
@@ -44,10 +45,12 @@ def apply_updates():
print("\nFinished updating pack!")
+
+# Using the latest urls, update downloads.txt to match the urls and have the correct sha1
def find_updates():
print("Reading update file...")
mods = set()
- with open('updates.txt') as f:
+ with open('latest-urls.txt') as f:
for line in f:
mod = line.strip().split()
if len(line) >= 1 and line[0] != '#':
@@ -58,18 +61,20 @@ def find_updates():
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]}...")
resp = requests.get(mod[1])
hsh = hashlib.sha1(resp.content)
f.write(f'{mod[0]} {hsh.hexdigest()} {resp.url}\n')
+ print("\nDone downloading updates!")
if len(sys.argv) < 2:
- print(f"Usage: {sys.argv[0]} <update|find_updates>")
+ print(f"Usage: {sys.argv[0]} <apply_updates|find_updates>")
sys.exit(-1)
-elif sys.argv[1] == 'update':
- update()
+elif sys.argv[1] == 'apply_updates':
+ apply_updates()
elif sys.argv[1] == 'find_updates':
find_updates()
else:
- print(f"Usage: {sys.argv[0]} <update|find_updates>")
+ print(f"Usage: {sys.argv[0]} <apply_updates|find_updates>")
sys.exit(-1)