Beispiel #1
0
    def process_source(self, url, config):
        """
        Process an individual source.  This runs the fetching of a 
        data source, determines which class should represent the output,
        and selects where the output goes.

        @param url: The string URL of the configuration.
        @param config: The configuration of the system.
        """
        type = config.get_source_type()
        today = datetime.datetime.today()
        file = config.get_format().gen_fmt_string(YEAR="%4d"%today.year,
                                                  MONTH="%02d"%today.month,
                                                  DAY="%02d"%today.day,
                                                  HOUR="%02d"%today.hour,
                                                  MINUTE="%02d"%today.minute,
                                                  SECOND="%02d"%today.second)
        file = "%s/%s" % (config.get_output_directory(), file)
	try:
            if type == WEB_SOURCE:
                source = WebSite(url, config)
                source.output_file(file)
            elif type == RSS_SOURCE:
                source = RSSReader(url, config) 
                source.output_file(file)
            elif type == RSYNC_SOURCE:
                source = Rsync(url, config)
        except Exception as inst:
            os.system("touch %s" % file)
            logger.warning("No Data found at '%s'" % url)