53 lines
1.6 KiB
Python
53 lines
1.6 KiB
Python
from hugvey.client import Hugvey
|
|
import logging
|
|
import logging.handlers
|
|
import coloredlogs
|
|
import argparse
|
|
from urllib.parse import urlparse
|
|
|
|
if __name__ == '__main__':
|
|
argParser = argparse.ArgumentParser(description='Start up a Hugvey pillow. Mic stream becomes available on TCP Socket, and starts listening + emitting events')
|
|
argParser.add_argument(
|
|
'--config',
|
|
'-c',
|
|
required=True,
|
|
type=str,
|
|
help='The yaml config file to load'
|
|
)
|
|
argParser.add_argument(
|
|
'--verbose',
|
|
'-v',
|
|
action="store_true",
|
|
)
|
|
argParser.add_argument(
|
|
'--id',
|
|
type=int,
|
|
default=None,
|
|
help="Force the given id to be used. Must be integer"
|
|
)
|
|
argParser.add_argument(
|
|
'--log',
|
|
action='store_true',
|
|
help="If given, logs are send to cutelog on the central command, if cutelog is not started this could significantly slow down the Hugvey"
|
|
)
|
|
|
|
args = argParser.parse_args()
|
|
|
|
coloredlogs.install(
|
|
level=logging.DEBUG if args.verbose else logging.INFO,
|
|
)
|
|
|
|
logger = logging.getLogger("hugvey")
|
|
# logger.setLevel(1) # to send all records to cutelog
|
|
|
|
|
|
hv = Hugvey(args.id)
|
|
hv.loadConfig(args.config)
|
|
|
|
if args.log:
|
|
host = urlparse(hv.config['events']['cmd_address']).hostname
|
|
logger.info("Connect to logger on {}".format(host))
|
|
socket_handler = logging.handlers.SocketHandler(host, 19996) # default listening address
|
|
logger.addHandler(socket_handler);
|
|
|
|
hv.start()
|