From e941f738ba435645f141126dad568ee12c4a9b72 Mon Sep 17 00:00:00 2001 From: Bonta-kun <40473493+Bonta0@users.noreply.github.com> Date: Sat, 18 Jan 2020 10:05:59 +0100 Subject: [PATCH] MultiClient: get rid of packages install hacks, use requirements.txt instead --- MultiClient.py | 43 +++++-------------------------------------- requirements.txt | 3 +++ 2 files changed, 8 insertions(+), 38 deletions(-) create mode 100644 requirements.txt diff --git a/MultiClient.py b/MultiClient.py index 89a04b6f..4ff25745 100644 --- a/MultiClient.py +++ b/MultiClient.py @@ -1,39 +1,16 @@ +import aioconsole import argparse import asyncio +import colorama import json import logging import shlex -import subprocess -import sys import urllib.parse +import websockets import Items 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: def __init__(self, item, location, player): @@ -731,12 +708,6 @@ async def console_loop(ctx : Context): if command[0] == '/exit': 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': ctx.snes_reconnect_address = None 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 if __name__ == '__main__': - if 'colorama' in sys.modules: - colorama.init() - + colorama.init() loop = asyncio.get_event_loop() loop.run_until_complete(main()) loop.run_until_complete(asyncio.gather(*asyncio.Task.all_tasks())) loop.close() - - if 'colorama' in sys.modules: - colorama.deinit() + colorama.deinit() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..061dd9fe --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +aioconsole==0.1.15 +colorama==0.4.3 +websockets==8.1