Skip to content

Commit

Permalink
Route unhandled errors to logger (+3 squashed commits)
Browse files Browse the repository at this point in the history
Add GUI

- only has run server option
- removed drc-sim-helper.py

Added get_key GUI

Update setup.py
  • Loading branch information
rolandoislas committed Mar 18, 2017
1 parent e155717 commit ce24aa0
Show file tree
Hide file tree
Showing 31 changed files with 1,095 additions and 758 deletions.
74 changes: 67 additions & 7 deletions drc-sim-backend.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,72 @@
import sys
from src.server.data import constants
from src.server.data.config_server import ConfigServer
from src.server.util.logging.logger_wpa import LoggerWpa
from src.server.data.args import Args
from src.server.ui.cli.cli_main import CliMain
from src.server.ui.gui.gui_main import GuiMain
from src.server.util.logging.logger import Logger
from src.server.util.logging.logger_backend import LoggerBackend
from src.server.util.logging.logger_cli import LoggerCli
from src.server.util.logging.logger_gui import LoggerGui
from src.server.util.os_util import OsUtil

from src.server.control.gamepad import Gamepad

gamepad = Gamepad()
while True:
def init_loggers():
loggers = (Logger, LoggerBackend, LoggerGui, LoggerCli, LoggerWpa)
for logger in loggers:
if Args.args.debug:
logger.set_level(Logger.DEBUG)
elif Args.args.extra:
logger.set_level(Logger.EXTRA)
elif Args.args.finer:
logger.set_level(Logger.FINER)
elif Args.args.verbose:
logger.set_level(Logger.VERBOSE)
else:
logger.set_level(Logger.INFO)


def start():
ui = None
try:
gamepad.update()
if Args.args.cli:
Logger.info("Enabling CLI")
ui = CliMain()
else:
Logger.info("Enabling GUI")
ui = GuiMain()
ui.start()
except KeyboardInterrupt:
gamepad.close()
sys.exit()
if ui:
ui.stop()
except Exception, e:
if ui:
ui.stop()
Logger.throw(e)
Logger.info("Exiting")


def log_level():
# Logger info
Logger.debug("Debug logging enabled")
Logger.extra("Extra debug logging enabled")
Logger.finer("Finer debug logging enabled")
Logger.verbose("Verbose logging enabled")
if LoggerWpa.get_level() <= Logger.FINER:
LoggerWpa.warn("At this log level SSIDs are logged!")


def main():
Args.parse_args()
ConfigServer.load()
ConfigServer.save()
init_loggers()
Logger.info("Initializing drc-sim-backend")
Logger.info("Using \"%s\" as home folder.", constants.PATH_ROOT)
log_level()
OsUtil.log_info(Logger)
start()


if __name__ == '__main__':
main()
Loading

0 comments on commit ce24aa0

Please sign in to comment.