def reportMissingEpgFiles(self, newestEpg): def missingEpgs(): """Yield a list of seconds relative to now that corresponds to a time where epg should have been downloaded. Very roughly.""" now = datetime.datetime.today() t = self.config.epgAgeLimit while now - t > newestEpg.getTimeOfLastModification(): yield (t.microseconds + (t.seconds + t.days * 24 * 3600) * 10**6) / 10**6 t += self.config.epgAgeLimit for epg in missingEpgs(): filename_ = createFilename(-epg) informer_ = StateInformer(filename_, self.config.stateMonitor) epgComponent_ = informer_.get(epgComponent) epgComponent_.failed() msg = "Missing EPG: " + filename_ logging.error(msg)
if len(sys.argv) != 2: print "Usage: %s config-file" % sys.argv[0] sys.exit(1) else: configFile = sys.argv[1] try: config = EpgConfig(configFile) except Exception as e: print "Error loading the config file: " + configFile raise else: rotateLogs(config) logging.basicConfig(filename=config.logFile,level=logging.INFO, format='%(asctime)s: %(message)s') filename = createFilename() informer = StateInformer(filename, config.stateMonitor) epgComponent_ = informer.get(epgComponent) try: downloader = YouseeEpgDownloader(config, informer, filename) logging.info("Created new %s for \"%s\", using \"%s\" as state monitor." % (downloader.__class__.__name__, filename, config.stateMonitor)) epgComponent_.started() (messages, errors) = downloader.run() except Exception as e: epgComponent_.failed(e.message) logging.error("Failed: %s" % filename) raise else: if errors > 0: epgComponent_.failed("\n".join(messages)) logging.error("Failed: %s" % filename) exitCode = 4