MultiClient: get rid of packages install hacks, use requirements.txt instead
This commit is contained in:
parent
f988f7671b
commit
e941f738ba
|
@ -1,39 +1,16 @@
|
||||||
|
import aioconsole
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import colorama
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import shlex
|
import shlex
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
import websockets
|
||||||
|
|
||||||
import Items
|
import Items
|
||||||
import Regions
|
import Regions
|
||||||
|
|
||||||
while True:
|
|
||||||
try:
|
|
||||||
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:
|
class ReceivedItem:
|
||||||
def __init__(self, item, location, player):
|
def __init__(self, item, location, player):
|
||||||
|
@ -731,12 +708,6 @@ async def console_loop(ctx : Context):
|
||||||
if command[0] == '/exit':
|
if command[0] == '/exit':
|
||||||
ctx.exit_event.set()
|
ctx.exit_event.set()
|
||||||
|
|
||||||
if command[0] == '/installcolors' and 'colorama' not in sys.modules:
|
|
||||||
subprocess.call([sys.executable, '-m', 'pip', 'install', '--upgrade', 'colorama'])
|
|
||||||
global colorama
|
|
||||||
import colorama
|
|
||||||
colorama.init()
|
|
||||||
|
|
||||||
if command[0] == '/snes':
|
if command[0] == '/snes':
|
||||||
ctx.snes_reconnect_address = None
|
ctx.snes_reconnect_address = None
|
||||||
asyncio.create_task(snes_connect(ctx, command[1] if len(command) > 1 else ctx.snes_address))
|
asyncio.create_task(snes_connect(ctx, command[1] if len(command) > 1 else ctx.snes_address))
|
||||||
|
@ -948,13 +919,9 @@ async def main():
|
||||||
await input_task
|
await input_task
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if 'colorama' in sys.modules:
|
colorama.init()
|
||||||
colorama.init()
|
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(main())
|
loop.run_until_complete(main())
|
||||||
loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks()))
|
loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks()))
|
||||||
loop.close()
|
loop.close()
|
||||||
|
colorama.deinit()
|
||||||
if 'colorama' in sys.modules:
|
|
||||||
colorama.deinit()
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
aioconsole==0.1.15
|
||||||
|
colorama==0.4.3
|
||||||
|
websockets==8.1
|
Loading…
Reference in New Issue