def test_should_run(self): # without last run file eq_(pid.should_run(self.pid_dir, self.job.rule), True) print 'hee --> %s %s' % (self.pid_dir,self.job.rule_name) self._make_temp_pid_file() # with last run file that's new d = Datefile(self.pid_dir, "%s.last_run" % self.job.rule_name, timestamp=datetime.utcnow()) print 'yo --> %s' % d.timestamp eq_(pid.should_run(self.pid_dir, self.job.rule), False) # with last run file that's old Datefile(self.pid_dir, "%s.last_run" % self.job.rule_name, timestamp=Datefile.EPOCH) eq_(pid.should_run(self.pid_dir, self.job.rule), False) os.remove('%s/%s.pid' % (self.pid_dir, self.job.rule_name)) # right date, with no pid Datefile(self.pid_dir, "%s.last_run" % self.job.rule_name, timestamp=Datefile.EPOCH) eq_(pid.should_run(self.pid_dir, self.job.rule), True)
def start(self): signal.signal(signal.SIGTERM, self.die) log.info('Starting Inferno...') auto_rules = get_rules(self.settings['rules_directory']) pid_dir = pid.pid_dir(self.settings) # keep cycling through the automatic rules while not self.stopped: # cycle through all the automatic rules for rule in auto_rules: if self.stopped: break # skip this rule # check if pid file exists if not rule.run or self.paused or not pid.should_run( pid_dir, rule): continue pid.create_pid(pid_dir, rule, 'N/A') pid.create_last_run(pid_dir, rule) self.run_rule(rule) time.sleep(1) self.die()
def test_should_run(self): # without last run file eq_(pid.should_run(self.pid_dir, self.job.rule), True) print "hee --> %s %s" % (self.pid_dir, self.job.rule_name) self._make_temp_pid_file() # with last run file that's new d = Datefile(self.pid_dir, "%s.last_run" % self.job.rule_name, timestamp=datetime.utcnow()) print "yo --> %s" % d.timestamp eq_(pid.should_run(self.pid_dir, self.job.rule), False) # with last run file that's old Datefile(self.pid_dir, "%s.last_run" % self.job.rule_name, timestamp=Datefile.EPOCH) eq_(pid.should_run(self.pid_dir, self.job.rule), False) os.remove("%s/%s.pid" % (self.pid_dir, self.job.rule_name)) # right date, with no pid Datefile(self.pid_dir, "%s.last_run" % self.job.rule_name, timestamp=Datefile.EPOCH) eq_(pid.should_run(self.pid_dir, self.job.rule), True)
def start(self): signal.signal(signal.SIGTERM, self.die) log.info('Starting Inferno...') auto_rules = get_rules(self.settings['rules_directory']) pid_dir = pid.pid_dir(self.settings) # keep cycling through the automatic rules while not self.stopped: # cycle through all the automatic rules for rule in auto_rules: if self.stopped: break # skip this rule # check if pid file exists if not rule.run or self.paused or not pid.should_run(pid_dir, rule): continue pid.create_pid(pid_dir, rule, 'N/A') self.run_rule(rule) time.sleep(1) self.die()