mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
move updater to own module
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user