Hello All.<br><br>I am trying to use values, retrieved from a config file, as kwargs and not having any luck.  Well at least I think that's what I'm trying to do ;)<br><br>Any suggestions would be most appreciated.<br>
<br>Here's the exception:<br><br><span style="font-family: courier new,monospace;">Traceback (most recent call last):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  File "c:\dev\LogServerMonitor\LogServerMonitor.py", line 246, in <module></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    sched.add_cron_job(check_logging_db, minute = '*/run_interval_quantity')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  File "c:\Python26\lib\site-packages\apscheduler\scheduler.py", line 249, in add_cron_job</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    second)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  File "c:\Python26\lib\site-packages\apscheduler\triggers.py", line 22, in __init__</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    self._compile_expressions(minutes, 'minute')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  File "c:\Python26\lib\site-packages\apscheduler\triggers.py", line 43, in _compile_expressions</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    compiled_expr_list = [compile_single(expr) for expr in expr_list]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">  File "c:\Python26\lib\site-packages\apscheduler\triggers.py", line 36, in compile_single</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    (expr, fieldname))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">ValueError: Unrecognized expression "*/run_interval_quantity" for field "minute"</span><br>
<br><br><br>An example of what I am doing is:<br>######################################################################################<br><span style="font-family: courier new,monospace;">Config File Contents:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">[RunInterval]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#How often the application queries the DB to look for the date of </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">#the last entry (Default every 1 Minute).</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#Valid RunInterval Quantities are integers > 0</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">RunIntervalQuantity: 1</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#Valid RunInterval Types are S=Seconds, M=Minutes, H=Hours, D=Days</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">RunIntervalType: M</span><br><br>##############################################################################################<br><br>My Code<br><br><br><span style="font-family: courier new,monospace;">config = ConfigParser.ConfigParser()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">try:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    config.readfp(open(config_file))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">except:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    sys.stderr.write('Config file, "%s", is missing or unreadable. Exiting.' % config_file)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    sys.stderr.write('ERROR: %s\r\n' % str(err))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    sys.exit(1)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def getOption(section, option):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    try:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        opt_value = config.get(section, option)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        return opt_value</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    except (ConfigParser.NoOptionError), err:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        sys.stderr.write( "Application requires \"%s\" be defined in the [%s] section of the config file %s\r\n" % (option, section, config_file))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        sys.stderr.write('ERROR: %s\r\n' % str(err))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        sys.exit(1)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def getOptionInt(section, option):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    try:</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        opt_value = config.getint(section, option)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        return opt_value</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    except (ValueError, ConfigParser.NoOptionError), err:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        sys.stderr.write("Application requires \"%s\" be defined as an Integer in the \"[%s]\" section of the config file %s" % (option, section, config_file))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">        sys.stderr.write('ERROR: %s\r\n' % str(err))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        sys.exit(1)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"># Start the scheduler</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">sched = Scheduler()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">sched.start()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">run_interval_quantity = getOptionInt('RunInterval', 'RunIntervalQuantity')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">run_interval_type = getOption('RunInterval', 'RunIntervalType')</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">if run_interval_type in ['S', 's']:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    sched.add_cron_job(check_logging_db, second = '*/run_interval_quantity')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">elif run_interval_type in ['M', 'm']:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    sched.add_cron_job(check_logging_db, minute = '*/run_interval_quantity') </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">elif run_interval_type in ['H', 'h']:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    sched.add_cron_job(check_logging_db, hour = '*/run_interval_quantity')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">elif run_interval_type in ['D', 'd']:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    sched.add_cron_job(check_logging_db, day = '*/run_interval_quantity')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">else:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    my_logger.warning('The value of RunIntervalType in the configuration file section RunInterval was not one of "S, M, H or D". Running LogServerMonitor application once per minute by default.')</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">    sched.add_cron_job(check_logging_db, minute = '*')</span><br><br>