# Path: spyder_terminal/server/common.py
# def create_app(shell, close_future=None):
#     """Create and return a tornado Web Application instance."""
#     settings = {"static_path": os.path.join(
#         os.path.dirname(__file__), "static")}
#     application = tornado.web.Application(routes.gen_routes(close_future),
#                                           debug=True,
#                                           serve_traceback=True,
#                                           autoreload=True, **settings)
#     application.term_manager = TermManager([shell])
#     return application


import argparse
import asyncio
import logging
import os
import sys
import coloredlogs
import tornado.web
import tornado.ioloop
from spyder_terminal.server.common import create_app




parser = argparse.ArgumentParser(
    description='Websocket-based bash terminal server')

parser.add_argument('--port',
                    default=8070,
                    help="TCP port to be listened on")
parser.add_argument('--shell',
                    default='bash',
                    help="name/path to the terminal process to execute")

LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
              '-35s %(lineno) -5d: %(message)s')

logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__)
coloredlogs.install(level='info')

clr = 'clear'
if os.name == 'nt':
    clr = 'cls'


def main(port, shell):
    """Create and setup a new tornado server."""
    LOGGER.info("Server is now at: 127.0.0.1:{}".format(port))
    LOGGER.info('Shell: {0}'.format(shell))

# Path: spyder_terminal/server/common.py
# def create_app(shell, close_future=None):
#     """Create and return a tornado Web Application instance."""
#     settings = {"static_path": os.path.join(
#         os.path.dirname(__file__), "static")}
#     application = tornado.web.Application(routes.gen_routes(close_future),
#                                           debug=True,
#                                           serve_traceback=True,
#                                           autoreload=True, **settings)
#     application.term_manager = TermManager([shell])
#     return application


# Path: spyder_terminal/server/__main__.py
import argparse
import asyncio
import logging
import os
import sys
import coloredlogs
import tornado.web
import tornado.ioloop
from spyder_terminal.server.common import create_app





parser = argparse.ArgumentParser(
    description='Websocket-based bash terminal server')

parser.add_argument('--port',
                    default=8070,
                    help="TCP port to be listened on")
parser.add_argument('--shell',
                    default='bash',
                    help="name/path to the terminal process to execute")

LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
              '-35s %(lineno) -5d: %(message)s')

logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__)
coloredlogs.install(level='info')

clr = 'clear'
if os.name == 'nt':
    clr = 'cls'


def main(port, shell):
    """Create and setup a new tornado server."""
    LOGGER.info("Server is now at: 127.0.0.1:{}".format(port))
    LOGGER.info('Shell: {0}'.format(shell))

    application = create_app(shell)