2019-07-09 16:44:56 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
2019-08-12 12:16:07 +00:00
|
|
|
import sys
|
2019-07-09 16:44:56 +00:00
|
|
|
|
2019-08-18 12:11:38 +00:00
|
|
|
from ycast import __version__
|
2019-07-09 16:44:56 +00:00
|
|
|
from ycast import server
|
|
|
|
|
|
|
|
logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.INFO)
|
|
|
|
|
|
|
|
|
|
|
|
def launch_server():
|
|
|
|
parser = argparse.ArgumentParser(description='vTuner API emulation')
|
|
|
|
parser.add_argument('-c', action='store', dest='config', help='Station configuration', default=None)
|
|
|
|
parser.add_argument('-l', action='store', dest='address', help='Listen address', default='0.0.0.0')
|
|
|
|
parser.add_argument('-p', action='store', dest='port', type=int, help='Listen port', default=80)
|
2019-08-18 11:51:07 +00:00
|
|
|
parser.add_argument('-d', action='store_true', dest='debug', help='Enable debug logging')
|
2019-07-09 16:44:56 +00:00
|
|
|
arguments = parser.parse_args()
|
2019-08-18 12:11:38 +00:00
|
|
|
logging.info("YCast (%s) server starting", __version__)
|
2019-08-18 11:51:07 +00:00
|
|
|
if arguments.debug:
|
|
|
|
logging.getLogger().setLevel(logging.DEBUG)
|
|
|
|
logging.debug("Debug logging enabled")
|
2019-08-19 11:42:19 +00:00
|
|
|
else:
|
|
|
|
logging.getLogger('werkzeug').setLevel(logging.WARNING)
|
2019-07-09 16:44:56 +00:00
|
|
|
server.run(arguments.config, arguments.address, arguments.port)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2019-08-12 12:16:07 +00:00
|
|
|
if sys.version_info[0] < 3:
|
|
|
|
logging.error("Unsupported Python version (Python %s). Minimum required version is Python 3.",
|
|
|
|
sys.version_info[0])
|
|
|
|
sys.exit(1)
|
2019-07-09 16:44:56 +00:00
|
|
|
launch_server()
|