From c2df56e15ef6980f2e17197b91b871b4dcca9aa0 Mon Sep 17 00:00:00 2001 From: KenwoodFox Date: Sat, 27 Nov 2021 21:32:52 -0500 Subject: [PATCH] Add magic debug values via cli --- companion_software/entrypoint.sh | 2 +- companion_software/houston/__main__.py | 18 +++++++++++++++++- companion_software/houston/houston.py | 7 ++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/companion_software/entrypoint.sh b/companion_software/entrypoint.sh index 4f26cd4..6e4cfbb 100755 --- a/companion_software/entrypoint.sh +++ b/companion_software/entrypoint.sh @@ -6,4 +6,4 @@ git pull pipenv install -r requirements.txt -pipenv run python -m houston +pipenv run python -m houston -v diff --git a/companion_software/houston/__main__.py b/companion_software/houston/__main__.py index 7e9b661..edf6aa4 100644 --- a/companion_software/houston/__main__.py +++ b/companion_software/houston/__main__.py @@ -3,12 +3,28 @@ # Kitsune Scientific import logging +import argparse import verboselogs import coloredlogs from houston.houston import Houston +# Get debug args +parser = argparse.ArgumentParser() +parser.add_argument( + '-d', '--debug', + help="Print lots of debugging statements", + action="store_const", dest="loglevel", const='DEBUG', + default='WARNING', +) +parser.add_argument( + '-v', '--verbose', + help="Be verbose", + action="store_const", dest="loglevel", const='INFO', +) +args = parser.parse_args() + # Install verbose logs verboselogs.install() @@ -16,7 +32,7 @@ verboselogs.install() logger = logging.getLogger('Houston_Log') # Install colored logs -coloredlogs.install(level='INFO', +coloredlogs.install(level=args.loglevel, logger=logger, fmt='%(asctime)s,%(msecs)03d %(hostname)s %(levelname)s %(message)s') # noqa: E501 diff --git a/companion_software/houston/houston.py b/companion_software/houston/houston.py index 0386048..5cf6bad 100644 --- a/companion_software/houston/houston.py +++ b/companion_software/houston/houston.py @@ -4,7 +4,7 @@ import time -import houston.robotstreamer.streamer +from houston.robotstreamer.streamer import RobotStreamer class Houston: @@ -12,10 +12,15 @@ class Houston: # Setup logger self.log = logger + # Setup robotstreamer + self.rs = RobotStreamer(self.log) + # We're ready to go! self.log.success('Ready to robot!') def run(self): + self.rs.run() + # Junk~ while True: try: