-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Route unhandled errors to logger (+3 squashed commits)
Add GUI - only has run server option - removed drc-sim-helper.py Added get_key GUI Update setup.py
- Loading branch information
1 parent
e155717
commit ce24aa0
Showing
31 changed files
with
1,095 additions
and
758 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.