Skip to content

Commit

Permalink
Move code in __main__.py into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
gideonshaked committed Jul 10, 2021
1 parent 2dcb117 commit dce02e5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/server/server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@

from . import movement_controller, receive_data

log_levels = {"INFO": logging.INFO, "DEBUG": logging.DEBUG}

log_level = log_levels[os.getenv("LOG_LEVEL", default="DEBUG")]
def main():
log_level = {"INFO": logging.INFO, "DEBUG": logging.DEBUG}[os.getenv("LOG_LEVEL", default="DEBUG")]

logging.basicConfig(
format="{asctime} {levelname}: {message}", style="{", level=log_level, datefmt="%m/%d/%Y %I:%M:%S %p"
)
logging.basicConfig(level=log_level, format="{levelname}: {message}", style="{")
logging.info(f"Log level: {log_level}")
logging.info(f"Server version: {__import__('server').__version__}")

logging.info(f"Log level: {log_level}")
logging.info(f"Server version: {__import__('server').__version__}")
atexit.register(movement_controller.clean_up)

atexit.register(movement_controller.clean_up)
movement_system_thread = Thread(target=movement_controller.run, daemon=True)
movement_system_thread.start()
logging.info("Movement system thread started.")
receive_data.serve()

movement_system_thread = Thread(target=movement_controller.run, daemon=True)
movement_system_thread.start()
logging.info("Movement system thread started.")

receive_data.serve()
if __name__ == "__main__":
main()

0 comments on commit dce02e5

Please sign in to comment.