Commits

t1m committed 912ef19

fixing inferno 'groundhog day' bug - automatic rules thought they were being run on the day inferno was started not date.today()

Comments (0)

Files changed (4)

inferno/bin/run.py

             logging.config.fileConfig(
                 log_config, disable_existing_loggers=False)
         except Exception as e:
-            log.error('Error setting up logging [%s]: %s' % (log_config, e))
+            log.error('Error setting up logging: %s' %  e)
             _log_stdout(log)
 
     log.info('Starting inferno-%s', __version__)

inferno/lib/job_options.py

-from datetime import timedelta
+from datetime import timedelta, date
 import functools
 import types
 
 
             # note that all day range options are disabled if we pass tags in
             # on the command line
+            count = None
             if self.settings.get('day_start') is not None:
                 start = self.settings.get('day_start')
+                count = 1
+            elif self.rule.day_start is not None:
+                start = self.rule.day_start
             else:
-                start = self.rule.day_start
+                start = date.today()
 
             if self.settings.get('day_offset') is not None:
                 start += timedelta(days=-self.settings.get('day_offset'))
+                count = 1
             else:
                 start += timedelta(days=-self.rule.day_offset)
 
             if self.settings.get('day_range') is not None:
                 count = self.settings.get('day_range')
-            else:
+            elif count is None:
                 count = self.rule.day_range
 
             if count and tags:

inferno/lib/rule.py

                  # input
                  day_range=0,
                  day_offset=0,
-                 day_start=date.today(),
+                 day_start=None,
                  source_tags=None,
                  source_urls=None,
 

test/lib/test_job_options.py

         rule = InfernoRule(source_tags=['tag5'], day_range=2)
         settings = InfernoSettings(day_start=date(2011, 12, 01))
         actual = JobOptions(rule, settings).tags
-        expected = ['tag5:2011-12-01', 'tag5:2011-11-30']
+        # even though day_range=2, we only expect 1 day, as the settings will override
+        # the rule
+        expected = ['tag5:2011-12-01']
         eq_(actual, expected)
 
     def test_explict_tags(self):