From afaad3cf2516f59ad74f486256bfeb114cf9b805 Mon Sep 17 00:00:00 2001 From: r58Playz <45221816+r58Playz@users.noreply.github.com> Date: Tue, 23 Apr 2019 17:04:55 -0700 Subject: [PATCH 1/5] Create update.py --- update.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 update.py diff --git a/update.py b/update.py new file mode 100644 index 00000000..c6b78dd4 --- /dev/null +++ b/update.py @@ -0,0 +1,20 @@ +import shutil +import os +import zipfile +import urllib.request +from io import BytesIO +def update(): + updatezip = urllib.request.urlopen('https://github.com/boskee/Minecraft/archive/master.zip') + zipref = zipfile.ZipFile(BytesIO(updatezip.read())) + zipref.extractall("pycraft_update") + zipref.close() + files=os.listdir("pycraft_update") + for fle in files: + full_filename = os.path.join("pycraft_update", fle) + if os.path.isfile(full_filename): + if file != "update.py": + current_dir=os.path.basename(os.getcwd()) + shutil.copy(full_filename, current_dir) + shutil.rmtree("pycraft_update") + import main # Wonder what happens if you put this at the top? A TRACEBACK! + main.start()# Should work... From 7a33b27188e94ac322d77633130ec24915dbdcf1 Mon Sep 17 00:00:00 2001 From: r58Playz <45221816+r58Playz@users.noreply.github.com> Date: Tue, 23 Apr 2019 17:06:57 -0700 Subject: [PATCH 2/5] Update main.py --- main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 1c6c16b2..02a6d0a8 100755 --- a/main.py +++ b/main.py @@ -144,8 +144,7 @@ def main(options): G.main_timer.stop() G.SERVER._stop.set() G.SERVER.shutdown() - -if __name__ == '__main__': +def start(): log_info('Starting pyCraft...') parser = argparse.ArgumentParser(description='Play a Python made Minecraft clone.') @@ -163,3 +162,7 @@ def main(options): options = parser.parse_args() main(options) + + +if __name__ == '__main__': + start() From 12875fe71a857abf4abe4f3f3af4fe9cce9d5d03 Mon Sep 17 00:00:00 2001 From: r58Playz <45221816+r58Playz@users.noreply.github.com> Date: Wed, 24 Apr 2019 07:37:10 -0700 Subject: [PATCH 3/5] Add update mechanism settings --- globals.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/globals.py b/globals.py index 7744868d..6f0a5e1c 100644 --- a/globals.py +++ b/globals.py @@ -226,6 +226,10 @@ config.read(config_file) LAUNCH_OPTIONS = argparse.Namespace() +# Update mechanism settings +UPDATE_URL = 'https://github.com/boskee/Minecraft/archive/master.zip' +UPDATE_TEMPDIR = "pycraft_update" + ANCHOR_NONE = 0 ANCHOR_LEFT = 1 ANCHOR_TOP = 1 << 1 From 7f238fa0675875f0c53479c180a1e9d573ce8c63 Mon Sep 17 00:00:00 2001 From: r58Playz <45221816+r58Playz@users.noreply.github.com> Date: Wed, 24 Apr 2019 07:40:03 -0700 Subject: [PATCH 4/5] Update update.py to reflect the settings in globals.py --- update.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/update.py b/update.py index c6b78dd4..d94a086d 100644 --- a/update.py +++ b/update.py @@ -1,20 +1,28 @@ +# Python packages import shutil import os import zipfile import urllib.request from io import BytesIO + +# Third-party libraries +# Nothing for now... + +# Modules from this project +import globals as G + def update(): - updatezip = urllib.request.urlopen('https://github.com/boskee/Minecraft/archive/master.zip') + updatezip = urllib.request.urlopen(G.UPDATE_URL) zipref = zipfile.ZipFile(BytesIO(updatezip.read())) - zipref.extractall("pycraft_update") + zipref.extractall(G.UPDATE_DIR) zipref.close() - files=os.listdir("pycraft_update") + files=os.listdir(G.UPDATE_DIR) for fle in files: - full_filename = os.path.join("pycraft_update", fle) + full_filename = os.path.join(G.UPDATE_DIR, fle) if os.path.isfile(full_filename): if file != "update.py": current_dir=os.path.basename(os.getcwd()) shutil.copy(full_filename, current_dir) - shutil.rmtree("pycraft_update") + shutil.rmtree(G.UPDATE_DIR) import main # Wonder what happens if you put this at the top? A TRACEBACK! main.start()# Should work... From 6ea66bb1abd0c8b621a7d7663613884fbe8fb05e Mon Sep 17 00:00:00 2001 From: r58Playz <45221816+r58Playz@users.noreply.github.com> Date: Wed, 24 Apr 2019 07:44:41 -0700 Subject: [PATCH 5/5] Update globals.py --- globals.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/globals.py b/globals.py index 6f0a5e1c..06bc2d83 100644 --- a/globals.py +++ b/globals.py @@ -226,10 +226,6 @@ config.read(config_file) LAUNCH_OPTIONS = argparse.Namespace() -# Update mechanism settings -UPDATE_URL = 'https://github.com/boskee/Minecraft/archive/master.zip' -UPDATE_TEMPDIR = "pycraft_update" - ANCHOR_NONE = 0 ANCHOR_LEFT = 1 ANCHOR_TOP = 1 << 1 @@ -241,6 +237,10 @@ DEFAULT_FONT = 'ChunkFive Roman' CHAT_FONT = 'Silkscreen' +# Update mechanism settings +UPDATE_URL = 'https://github.com/boskee/Minecraft/archive/master.zip' +UPDATE_TEMPDIR = "pycraft_update" + class InvalidChoice(Exception): pass