moonraker: refactor references to cmd_line_args
They are now named "system_args", as they represent system wide arguments. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
f96fb997da
commit
2e9c6de5d0
|
@ -129,7 +129,7 @@ class MoonrakerApp:
|
||||||
self.get_handler_delegate = self.app.get_handler_delegate
|
self.get_handler_delegate = self.app.get_handler_delegate
|
||||||
|
|
||||||
# Register handlers
|
# Register handlers
|
||||||
logfile = config['cmd_args'].get('logfile')
|
logfile = config['system_args'].get('logfile')
|
||||||
self.register_static_file_handler("moonraker.log", logfile)
|
self.register_static_file_handler("moonraker.log", logfile)
|
||||||
self.auth.register_handlers(self)
|
self.auth.register_handlers(self)
|
||||||
|
|
||||||
|
|
|
@ -70,9 +70,9 @@ class ConfigHelper:
|
||||||
return self._get_item(
|
return self._get_item(
|
||||||
self.config[self.section].getfloat, option, default)
|
self.config[self.section].getfloat, option, default)
|
||||||
|
|
||||||
def get_configuration(server, cmd_line_args):
|
def get_configuration(server, system_args):
|
||||||
cfg_file_path = os.path.normpath(os.path.expanduser(
|
cfg_file_path = os.path.normpath(os.path.expanduser(
|
||||||
cmd_line_args.configfile))
|
system_args.configfile))
|
||||||
if not os.path.isfile(cfg_file_path):
|
if not os.path.isfile(cfg_file_path):
|
||||||
raise ConfigError(f"Configuration File Not Found: '{cfg_file_path}''")
|
raise ConfigError(f"Configuration File Not Found: '{cfg_file_path}''")
|
||||||
config = configparser.ConfigParser(interpolation=None)
|
config = configparser.ConfigParser(interpolation=None)
|
||||||
|
@ -89,5 +89,5 @@ def get_configuration(server, cmd_line_args):
|
||||||
if server_cfg.get('enable_debug_logging', True):
|
if server_cfg.get('enable_debug_logging', True):
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
|
|
||||||
config['cmd_args'] = {'logfile': cmd_line_args.logfile}
|
config['system_args'] = {'logfile': system_args.logfile}
|
||||||
return ConfigHelper(server, config, 'server')
|
return ConfigHelper(server, config, 'server')
|
||||||
|
|
|
@ -101,7 +101,7 @@ class Server:
|
||||||
|
|
||||||
# check for optional plugins
|
# check for optional plugins
|
||||||
opt_sections = set([s.split()[0] for s in config.sections()]) - \
|
opt_sections = set([s.split()[0] for s in config.sections()]) - \
|
||||||
set(['server', 'authorization', 'cmd_args'])
|
set(['server', 'authorization', 'system_args'])
|
||||||
for section in opt_sections:
|
for section in opt_sections:
|
||||||
self.load_plugin(config, section, None)
|
self.load_plugin(config, section, None)
|
||||||
|
|
||||||
|
@ -550,11 +550,11 @@ def main():
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-l", "--logfile", default="/tmp/moonraker.log", metavar='<logfile>',
|
"-l", "--logfile", default="/tmp/moonraker.log", metavar='<logfile>',
|
||||||
help="log file name and location")
|
help="log file name and location")
|
||||||
cmd_line_args = parser.parse_args()
|
system_args = parser.parse_args()
|
||||||
|
|
||||||
# Setup Logging
|
# Setup Logging
|
||||||
log_file = os.path.normpath(os.path.expanduser(cmd_line_args.logfile))
|
log_file = os.path.normpath(os.path.expanduser(system_args.logfile))
|
||||||
cmd_line_args.logfile = log_file
|
system_args.logfile = log_file
|
||||||
ql = utils.setup_logging(log_file)
|
ql = utils.setup_logging(log_file)
|
||||||
|
|
||||||
if sys.version_info < (3, 7):
|
if sys.version_info < (3, 7):
|
||||||
|
@ -570,7 +570,7 @@ def main():
|
||||||
estatus = 0
|
estatus = 0
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
server = Server(cmd_line_args)
|
server = Server(system_args)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("Moonraker Error")
|
logging.exception("Moonraker Error")
|
||||||
estatus = 1
|
estatus = 1
|
||||||
|
|
Loading…
Reference in New Issue