move updater to own module
This commit is contained in:
parent
ec95e4ab5e
commit
b58558eb75
|
@ -15,3 +15,5 @@ EnemizerCLI/
|
|||
.mypy_cache/
|
||||
RaceRom.py
|
||||
weights/
|
||||
/MultiMystery/
|
||||
/Players/
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
import sys
|
||||
import subprocess
|
||||
import importlib
|
||||
|
||||
update_ran = False
|
||||
|
||||
def update_command():
|
||||
subprocess.call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt', '--upgrade'])
|
||||
|
||||
def update():
|
||||
global update_ran
|
||||
if not update_ran:
|
||||
update_ran = True
|
||||
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()
|
||||
|
||||
if __name__ == "__main__":
|
||||
update()
|
|
@ -3,41 +3,18 @@ import asyncio
|
|||
import json
|
||||
import logging
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import urllib.parse
|
||||
import importlib
|
||||
|
||||
import ModuleUpdate
|
||||
ModuleUpdate.update()
|
||||
|
||||
import colorama
|
||||
import websockets
|
||||
import aioconsole
|
||||
|
||||
import Items
|
||||
import Regions
|
||||
|
||||
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
|
||||
import websockets
|
||||
import colorama
|
||||
|
||||
class ReceivedItem:
|
||||
def __init__(self, item, location, player):
|
||||
self.item = item
|
||||
|
|
|
@ -56,6 +56,10 @@ def feedback(text:str):
|
|||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
|
||||
import ModuleUpdate
|
||||
ModuleUpdate.update()
|
||||
|
||||
print(f"{__author__}'s MultiMystery Launcher V{__version__}")
|
||||
if not os.path.exists(enemizer_location):
|
||||
feedback(f"Enemizer not found at {enemizer_location}, please adjust the path in MultiMystery.py's config or put Enemizer in the default location.")
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import aioconsole
|
||||
import argparse
|
||||
import asyncio
|
||||
import functools
|
||||
|
@ -7,9 +6,14 @@ import logging
|
|||
import re
|
||||
import shlex
|
||||
import urllib.request
|
||||
import websockets
|
||||
import zlib
|
||||
|
||||
import ModuleUpdate
|
||||
ModuleUpdate.update()
|
||||
|
||||
import websockets
|
||||
import aioconsole
|
||||
|
||||
import Items
|
||||
import Regions
|
||||
from MultiClient import ReceivedItem, get_item_name_from_id, get_location_name_from_address
|
||||
|
@ -348,7 +352,7 @@ async def console(ctx : Context):
|
|||
if receiving_player == slot and item_id == seeked_item_id:
|
||||
location_id, finding_player = check
|
||||
name_finder = ctx.player_names[team, finding_player]
|
||||
hint = f"[Hint]: {name}'s {item} can be found in " \
|
||||
hint = f"[Hint]: {name}'s {item} can be found at " \
|
||||
f"{get_location_name_from_address(location_id)} in {name_finder}'s World"
|
||||
notify_team(ctx, team, hint)
|
||||
else:
|
||||
|
|
|
@ -25,14 +25,12 @@ Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Palace o
|
|||
Notice (Team #1): [Hint]: Berserker's Progressive Sword can be found in Ganons Tower - Map Chest in Will's World
|
||||
|
||||
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
|
||||
* When an error is generated due to a broken .yaml file, it now mentions in the error trace which file it is
|
||||
|
||||
MultiClient.py
|
||||
Project
|
||||
* 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
|
||||
* Allow newer versions of modules than specified, as they will *usually* not break compatibility
|
||||
|
Loading…
Reference in New Issue