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 sys
import urllib.parse
import importlib
import Items
import Regions
while True:
def update_command():
subprocess.call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt', '--upgrade'])
with open('requirements.txt') as requirementsfile:
for line in requirementsfile.readlines():
module, remoteversion = line.split(">=")
try:
module = importlib.import_module(module)
except:
import traceback
traceback.print_exc()
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()
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:
try:
import websockets
break
except ImportError:
websockets = None
print('Required python module "websockets" not found, press enter to install it')
input()
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'websockets'])
try:
import colorama
except ImportError:
colorama = None
class ReceivedItem:
def __init__(self, item, location, player):

View File

@ -9,15 +9,15 @@ Additions/Changes
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.
* 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.
MultiServer.py
* 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)
* can be used as /hint Playername Itemname
* All Itemnames can be found in Items.py starting at line 25
* example
can be used as /hint Playername Itemname
All Itemnames can be found in Items.py starting at line 25
example:
/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 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
* Fix fast_ganon not working at all currently
* 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
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
colorama==0.4.3
websockets==8.1
aioconsole>=0.1.15
colorama>=0.4.3
websockets>=8.1