Exemplo n.º 1
0
    def run(self, callback, recursive=False):
        print '{} start.TODO/Total: {}/{}'.\
            format(self.name, self.count_todo(), self.count_total())
        key = self._next()
        while key:
            log.info('downloading {}-{}'.format(self.name, key))
            try:
                items = callback(key)
                log.info('{} items in {}-{}'.format(len(items), self.name,
                                                    key))
                if len(items) == 0:
                    send(u'Warning! May be banned. key={}'.format(key))
                if recursive:
                    self._add(*items)
            except Exception as e:
                log.error('{}. ID={}'.format(e, key))
                send(u'Info! meet exceptions. key={}, err={}'.format(key, e))
                self.db.rpush(self.todo_tbl, key)
            key = self._next()

        info = '{} done. {} got'.format(self.name, self.count_total())
        print(info)
        log.warning(info)
Exemplo n.º 2
0
    def run(self, callback, recursive=False):
        print '{} start.TODO/Total: {}/{}'.\
            format(self.name, self.count_todo(), self.count_total())
        key = self._next()
        while key:
            log.info('downloading {}-{}'.format(self.name, key))
            try:
                items = callback(key)
                log.info(
                    '{} items in {}-{}'.format(
                        len(items), self.name, key))
                if len(items) == 0:
                    send(u'Warning! May be banned. key={}'.format(key))
                if recursive:
                    self._add(*items)
            except Exception as e:
                log.error('{}. ID={}'.format(e, key))
                send(u'Info! meet exceptions. key={}, err={}'.format(key, e))
                self.db.rpush(self.todo_tbl, key)
            key = self._next()

        info = '{} done. {} got'.format(self.name, self.count_total())
        print(info)
        log.warning(info)
Exemplo n.º 3
0
# -*- Encoding: utf-8 -*-
from wechat import send

send(u'亲爱的')