Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create update mechanism #93

Closed
wants to merge 14 commits into from
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,8 @@ def main(options):
G.main_timer.stop()
G.SERVER._stop.set()
G.SERVER.shutdown()

if __name__ == '__main__':
log_info('Starting pyCraft...')
def start():
log_info('Starting pyCraft...')

parser = argparse.ArgumentParser(description='Play a Python made Minecraft clone.')

Expand All @@ -163,3 +162,5 @@ def main(options):

options = parser.parse_args()
main(options)
if __name__ == '__main__':
start()
20 changes: 20 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import shutil
import os
import zipfile
import urllif.request

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...
4 changes: 4 additions & 0 deletions views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
button_disabled, resize_button_image
from textures import TexturePackList
from utils import image_sprite, load_image
from update import update as up

__all__ = (
'View', 'MainMenuView', 'OptionsView', 'ControlsView', 'TexturesView', 'MultiplayerView'
Expand Down Expand Up @@ -256,6 +257,9 @@ def setup(self):
button = self.Button(caption=G._("Exit game"),on_click=self.controller.exit_game)
self.layout.add(button)
self.buttons.append(button)
button = self.Button(caption=G._("Update game"), on_click=up)
self.layout.add(button)
self.buttons.append(button)

# Splash text
self.splash_text = 'Hello!'
Expand Down