X-Git-Url: https://git.distorted.org.uk/~mdw/hippotat/blobdiff_plain/1cc6968f38db0ade45242e08f9aab1b1db3e43b1..2b13e1cc46b86b15a1522b225cde77e3e946f4cf:/hippotatlib/__init__.py diff --git a/hippotatlib/__init__.py b/hippotatlib/__init__.py index 701a5f2..4c7dd90 100644 --- a/hippotatlib/__init__.py +++ b/hippotatlib/__init__.py @@ -546,7 +546,7 @@ def common_startup(process_cfg): # is a directory log('directory') re = regexp.compile('[^-A-Za-z0-9_]') - for f in os.listdir(cdir): + for f in os.listdir(pathname): if re.search(f): continue subpath = pathname + '/' + f try: @@ -562,6 +562,19 @@ def common_startup(process_cfg): need_defcfg = False readconfig(value) + def oc_extra_config(od,os, value, op): + readconfig(value) + + def read_defconfig(): + readconfig('/etc/hippotat/config.d', False) + readconfig('/etc/hippotat/passwords.d', False) + readconfig('/etc/hippotat/master.cfg', False) + + def oc_defconfig(od,os, value, op): + nonlocal need_defcfg + need_defcfg = False + read_defconfig(value) + def dfs_less_detailed(dl): return [df for df in DBG.iterconstants() if df <= dl] @@ -625,12 +638,23 @@ just `+': all DFLAGs. action='callback', callback= oc_config) + optparser.add_option('--extra-config', + nargs=1, + type='string', + metavar='CONFIGFILE', + dest='configfile', + action='callback', + callback= oc_extra_config) + + optparser.add_option('--default-config', + action='callback', + callback= oc_defconfig) + (opts, args) = optparser.parse_args() if len(args): optparser.error('no non-option arguments please') if need_defcfg: - readconfig('/etc/hippotat/config', False) - readconfig('/etc/hippotat/config.d', False) + read_defconfig() try: (pss, pcs) = _cfg_process_putatives() @@ -650,15 +674,16 @@ just `+': all DFLAGs. stdsomething_obs = twisted.logger.FilteringLogObserver( stderr_obs, [pred], stdout_obs ) - log_observer = twisted.logger.FilteringLogObserver( + global file_log_observer + file_log_observer = twisted.logger.FilteringLogObserver( stdsomething_obs, [LogNotBoringTwisted()] ) #log_observer = stdsomething_obs twisted.logger.globalLogBeginner.beginLoggingTo( - [ log_observer, crash_on_critical ] + [ file_log_observer, crash_on_critical ] ) def common_run(): log_debug(DBG.INIT, 'entering reactor') if not _crashing: reactor.run() - print('CRASHED (end)', file=sys.stderr) + print('ENDED', file=sys.stderr)