示例#1
0
    def __create_owners_dir_mapping(self):

        self.__dir_mapping = dict()
        for owner in self.__context["owners"]:
            path = os.path.join(get_from_config(self.__config, "TUMBLR", "save_to_dir"), owner)
            if not os.path.isdir(path):
                os.makedirs(path)
            self.__dir_mapping[owner] = path
示例#2
0
    def __create_owners_dir_mapping(self):

        self.__dir_mapping = dict()
        for owner in self.__context['owners']:
            path = os.path.join(
                get_from_config(self.__config, 'TUMBLR', 'save_to_dir'), owner)
            if not os.path.isdir(path):
                os.makedirs(path)
            self.__dir_mapping[owner] = path
示例#3
0
    def __init__(self, config_file):

        self.__config_file = config_file
        self.__config = ConfigParser.SafeConfigParser()
        self.__config.read(config_file)
        self.__get_logging()
        self.__me_name = get_from_config(self.__config, 'TUMBLR', 'me_name')
        self.__me__pasword = get_from_config(self.__config, 'TUMBLR',
                                             'me_password')
        self.__me_mail = get_from_config(self.__config, 'TUMBLR', 'me_email')
        self.__me_max = get_from_config(self.__config, 'TUMBLR', 'me_max')
        self.__acounts = [
            item.strip() for item in get_from_config(self.__config, 'TUMBLR',
                                                     'accounts').split(',')
        ]
        self.__limit = get_from_config(self.__config, 'TUMBLR', 'limit', 0)
        self.__context = {'owners': self.__acounts}
        self.__task_queue = Queue.Queue(QUEUE_MAX_SIZE)
        self.__image_crawlers = list()
        for account in self.__acounts:
            self.__image_crawlers.append(
                TumblrImageCrawler(task_queue=self.__task_queue,
                                   name=account,
                                   max=self.__me_max,
                                   limit=self.__limit))
        self.__context['image_crawlers'] = self.__image_crawlers
        self.__save_thread = PhotoSaveThread(self.__config, self.__task_queue,
                                             self.__context)
        self.__log.info('I am: %r', self.__class__.__name__)
示例#4
0
    def __init__(self, config_file):

        self.__config_file = config_file
        self.__config = ConfigParser.SafeConfigParser()
        self.__config.read(config_file)
        self.__get_logging()
        self.__me_name = get_from_config(self.__config, "TUMBLR", "me_name")
        self.__me__pasword = get_from_config(self.__config, "TUMBLR", "me_password")
        self.__me_mail = get_from_config(self.__config, "TUMBLR", "me_email")
        self.__me_max = get_from_config(self.__config, "TUMBLR", "me_max")
        self.__acounts = [item.strip() for item in get_from_config(self.__config, "TUMBLR", "accounts").split(",")]
        self.__limit = get_from_config(self.__config, "TUMBLR", "limit", 0)
        self.__context = {"owners": self.__acounts}
        self.__task_queue = Queue.Queue(QUEUE_MAX_SIZE)
        self.__image_crawlers = list()
        for account in self.__acounts:
            self.__image_crawlers.append(
                TumblrImageCrawler(task_queue=self.__task_queue, name=account, max=self.__me_max, limit=self.__limit)
            )
        self.__context["image_crawlers"] = self.__image_crawlers
        self.__save_thread = PhotoSaveThread(self.__config, self.__task_queue, self.__context)
        self.__log.info("I am: %r", self.__class__.__name__)