Exemplo n.º 1
0
    import uvloop
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
except ImportError:
    print("uvloop is not install")

parser = argparse.ArgumentParser(description='app api_es')
parser.add_argument('--host', help='Host to listen', default='0.0.0.0')
parser.add_argument('--port',
                    help='Port to accept connections',
                    default='5000')
parser.add_argument('--reload',
                    action='store_true',
                    help='Auto reload code on change')
parser.add_argument('-c',
                    '--config',
                    type=argparse.FileType('r'),
                    help='Path to configuration file')

args = parser.parse_args()
config = load_config(args.config)
app = create_app(config=config)

if args.reload:
    print('Start with code reload')
    import aioreloader
    aioreloader.start()

if __name__ == '__main__':
    logging.basicConfig(
        level=getattr(logging, config.get('LOGGING_LEVEL', 'DEBUG')))
    aiohttp.web.run_app(app, host=args.host, port=args.port)
Exemplo n.º 2
0
parser.add_argument(
    '--debug',
    action='store_true',
    help='Debug code'
)
parser.add_argument(
    '-c',
    '--config',
    type=argparse.FileType('r'),
    help='Path to configuration file'
)

args = parser.parse_args()

# reload
if args.reload:
    print('Start with code reload')
    import aioreloader
    aioreloader.start()

# logging
if args.debug:
    print('Start with debug')
    logging.basicConfig(level=logging.DEBUG)

# app
app = create_app(config=load_config(args.config))

if __name__ == '__main__':
    aiohttp.web.run_app(app, host=args.host, port=args.port)
Exemplo n.º 3
0
import random

from src import engine
from src import logs
from src import settings
from src.textio import input_color, print_color

logger = logs.get_logger()

cfg_engine = settings.load_config('engine')


def input_gamemode(gamemodes):
    print_color(f"Gamemodes: {', '.join(gamemodes[1:])}")
    gamemodes = [gm.casefold() for gm in gamemodes]

    gamemode = input_color(
        'Type a gamemode (case-insensitive) to play it,\n'
        f'or nothing to skip. {cfg_engine.GAME_SETUP_INPUT_COLOR}').casefold()

    while gamemode not in gamemodes:
        gamemode = input_color(
            'Unknown gamemode; check spelling: '
            f'{cfg_engine.GAME_SETUP_INPUT_COLOR}').casefold()

    logger.debug(f'Got gamemode from user: {gamemode!r}')
    return gamemode


def stop_randomization_of_moves(battle, *, A=True, B=True):
    """Remove keys in a battle environment telling the game loop to randomize
Exemplo n.º 4
0
try:
    if platform.system() == 'Windows':
        # For Windows, do this instead of just import readline;
        # it screws with colours on prompting
        import pyreadline as readline
    else:
        import readline
except ModuleNotFoundError:
    readline = None
    if platform.system() == 'Windows':
        logger.info('Missing readline module, auto-completion not available; '
                    'install "pyreadline" module to resolve')
    else:
        logger.info('Missing readline module, auto-completion not available')

cfg_engine = settings.load_config('engine')
cfg_interface = settings.load_config('interface')


class FighterBattleShell:
    """To be inherited by other battle shells along with cmd.Cmd."""
    intro = ''  # Message when shell is opened
    prompt_default = '> '
    prompt = prompt_default  # Input prompt

    ruler = '='  # Used for help message headers
    doc_leader = ''  # Printed before the documentation headers
    doc_header = 'Commands (type help <command>):'
    misc_header = 'Help topics (type help <topic>):'
    # undoc_header should not show up because all commands
    # should have documentation