From 0ae30d1679e12642e7bc73dcc2df078c27644366 Mon Sep 17 00:00:00 2001 From: Alexander Hayden Date: Fri, 9 Nov 2018 20:38:13 -0500 Subject: Initial Commit --- update.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 update.py (limited to 'update.py') diff --git a/update.py b/update.py new file mode 100755 index 0000000..11c6b4c --- /dev/null +++ b/update.py @@ -0,0 +1,39 @@ +#!/bin/python3 + +from urllib.request import urlretrieve +from os import listdir, remove +from shutil import rmtree + +INSTALL_DIR = "" +with open("pack-location.txt", "r") as f: + INSTALL_DIR = f.read().strip() + +DOWNLOADS = [] +NAMES = set() +FILES = listdir(INSTALL_DIR) + +with open("downloads.txt", "r") as f: + for line in f: + dl = line.strip().split(" ") + if len(line) > 3 and len(dl) == 2 and line[0] != '#': + dl[0] = dl[0].strip() + dl[1] = dl[1].strip() + DOWNLOADS.append(dl) + NAMES.add(dl[0]) + +print("Updating pack...") +for mod in DOWNLOADS: + if mod[0] in FILES: + print("Skipping " + mod[0] + ", already up-to-date") + else: + print("Installing " + mod[0] + " from " + mod[1] + "...") + urlretrieve(mod[1], INSTALL_DIR + "/" + mod[0]) + print("Done!") + +print("\nRemoving old versions...") +for jar in FILES: + if jar not in NAMES and jar[-4:] == ".jar": + remove(INSTALL_DIR + "/" + jar) + print("Removing '" + jar + "'") + +print("\nFinished updating pack!") -- cgit v1.2.3