re-implement auto-updates

This commit is contained in:
Fabian Dill 2020-01-18 15:04:39 +01:00
parent 72c33a2348
commit 674cad07ea
3 changed files with 39 additions and 32 deletions

View File

@ -6,34 +6,37 @@ import shlex
import subprocess import subprocess
import sys import sys
import urllib.parse import urllib.parse
import importlib
import Items import Items
import Regions import Regions
while True: def update_command():
try: subprocess.call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt', '--upgrade'])
import aioconsole
break
except ImportError:
aioconsole = None
print('Required python module "aioconsole" not found, press enter to install it')
input()
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'aioconsole'])
while True: with open('requirements.txt') as requirementsfile:
try: for line in requirementsfile.readlines():
import websockets module, remoteversion = line.split(">=")
break try:
except ImportError: module = importlib.import_module(module)
websockets = None except:
print('Required python module "websockets" not found, press enter to install it') import traceback
input() traceback.print_exc()
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'websockets']) input(f'Required python module {module} not found, press enter to install it')
update_command()
else:
if hasattr(module, "__version__"):
module_version = module.__version__
module = module.__name__ #also unloads the module to make it writable
if type(module_version) == str:
module_version = tuple(int(part.strip()) for part in module_version.split("."))
remoteversion = tuple(int(part.strip()) for part in remoteversion.split("."))
if module_version < remoteversion:
input(f'Required python module {module} is outdated ({module_version}<{remoteversion}), press enter to upgrade it')
update_command()
try: import aioconsole
import colorama import websockets
except ImportError: import colorama
colorama = None
class ReceivedItem: class ReceivedItem:
def __init__(self, item, location, player): def __init__(self, item, location, player):

View File

@ -9,15 +9,15 @@ Additions/Changes
MultiMystery.py MultiMystery.py
* Allows you to generate a Multiworld with individual player mystery weights. Since weights can also be set to 100%, this also allows for individual settings for each player in a regular multiworld. * Allows you to generate a Multiworld with individual player mystery weights. Since weights can also be set to 100%, this also allows for individual settings for each player in a regular multiworld.
* Basis is a .yaml file that sets these weights. You can find an easy.yaml in this project folder to get started. Basis is a .yaml file that sets these weights. You can find an easy.yaml in this project folder to get started.
* Additional instructions and settings are at the start of the file. Open with a text editor. * Additional instructions and settings are at the start of the file. Open with a text editor.
MultiServer.py MultiServer.py
* Added a try/except to prevent malformed console commands from crashing the entire server * Added a try/except to prevent malformed console commands from crashing the entire server
* Added /hint command on the server (use just /hint for help on command) * Added /hint command on the server (use just /hint for help on command)
* can be used as /hint Playername Itemname can be used as /hint Playername Itemname
* All Itemnames can be found in Items.py starting at line 25 All Itemnames can be found in Items.py starting at line 25
* example example:
/hint Berserker Progressive Sword /hint Berserker Progressive Sword
Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Hype Cave - Top in ahhdurr's World Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Hype Cave - Top in ahhdurr's World
Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Blind's Hideout - Far Right in Schulzer's World Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Blind's Hideout - Far Right in Schulzer's World
@ -27,8 +27,12 @@ Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Ganons T
Mystery.py Mystery.py
* Fix fast_ganon not working at all currently * Fix fast_ganon not working at all currently
* Defaults to generating a non-race ROM (Bonta's only makes race ROMs at this time) * Defaults to generating a non-race ROM (Bonta's only makes race ROMs at this time)
* If a race ROM is desired, pass --create-race as argument to it If a race ROM is desired, pass --create-race as argument to it
* When an error is generated due to a broken .yaml file, it now mentions in the error trace which file it is * When an error is generated due to a broken .yaml file, it now mentions in the error trace which file it is
MultiClient.py MultiClient.py
* Update websockets if it is too old, preventing a crash when trying to connect * Update modules if they are too old, preventing a crash when trying to connect among potential other issues
* Autoinstall missing modules
Project
* Allow newer versions of modules than specified, as they will *usually* not break compatibility

View File

@ -1,3 +1,3 @@
aioconsole==0.1.15 aioconsole>=0.1.15
colorama==0.4.3 colorama>=0.4.3
websockets==8.1 websockets>=8.1