当前位置: 首页>>代码示例>>Python>>正文


Python LOGGER.error方法代码示例

本文整理汇总了Python中config.LOGGER.error方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.error方法的具体用法?Python LOGGER.error怎么用?Python LOGGER.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在config.LOGGER的用法示例。


在下文中一共展示了LOGGER.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def run(self):
     flag = True
     try:
         self.socket.connect((HOST ,PORT))
     except error:
         print 'connection failed'
         return
     print 'connected to server %s:%s' % (HOST, PORT)
     while flag:
         try:
             if not self.controler.stoped:
                 if self.task == 'random':
                     uid, pages = self.request(action='getuid')
                     self.travel(uid=uid, pages=pages)
                     time.sleep(1)
                 elif self.task == 'target':
                     uid = self.request(action='gettargetuid')
                     self.target_travel(time.time()-24*60*60, uid=uid)
                     time.sleep(1)
                 else:
                     pass
             else:
                 time.sleep(1)
         except Exception, e:
             LOGGER.error('Unhandled Error:%s' % e)
开发者ID:lijiahong,项目名称:WeMining,代码行数:27,代码来源:SoupSpider.py

示例2: run

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def run(self):
     while True:
         try:
             if not self.data_queue.empty():
                 data = self.data_queue.get()
                 if hasattr(data, 'target_statuses'):
                    for status in data.target_statuses:
                       exist = self.db['target_statuses'].find({'_id': status['_id']}).count()
                       if not exist:
                           self.db['target_statuses'].insert(status)
                 if hasattr(data, 'statuses'):
                     posts = []
                     for status in data.statuses:
                         exist = self.db.statuses.find({'_id': status['_id']}).count()
                         if not exist:
                             posts.append(status)
                     if len(posts):
                         self.db.statuses.insert(posts)
                 if hasattr(data, 'users'):
                     for user in data.users:
                         exist = self.db.users.find_one({'_id': user['_id']})
                         if not exist:
                             self.users.insert(user)
                 if hasattr(data, 'user'):
                     self.db.users.save(data.user)
             else:
                 if self.stoped:
                     break
                 else:
                     time.sleep(0.5)
         except Exception, e:
             LOGGER.error(e)
             continue
开发者ID:lijiahong,项目名称:WeMining,代码行数:35,代码来源:SpiderServer.py

示例3: webhookHandler

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
def webhookHandler(event):
    """ Travese to webhook handler and let it deal with the error.
    """
    try:
        return event.error['context'].restrictedTraverse(
            '@@logbook_webhook')(event)
    except Exception, e:
        LOGGER.error(
            "An error occured while notifying with webhooks: %s" % str(e))
开发者ID:miohtama,项目名称:collective.logbook-1,代码行数:11,代码来源:events.py

示例4: gettargetuid

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def gettargetuid(self):
     self.socket.sendall(json.dumps({'action': 'gettargetuid'})+'\r\n')
     res = self.socket.recv(1024)
     r = json.loads(res, object_hook=_obj_hook)
     if hasattr(r, 'error'):
         LOGGER.error(r.error)
         return None
     else:
         return r.uid
开发者ID:lijiahong,项目名称:WeMining,代码行数:11,代码来源:SoupSpider.py

示例5: mailHandler

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
def mailHandler(event):
    """ notify this error
    """
    try:
        return event.error['context'].restrictedTraverse(
            '@@logbook_mail')(event)
    except Exception, e:
        LOGGER.error(
            "An error occured while notifying recipients: %s" % str(e))
开发者ID:miohtama,项目名称:collective.logbook-1,代码行数:11,代码来源:events.py

示例6: add_good

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
def add_good(user, password, data, opener):
    LOGGER.info('!!Found good: %r %r', user, password)
    with kLock:
        known_users.add(user)
    try:
        acc_data = account_data(user, password, data, opener)
        GOOD.put(acc_data)
    except ValueError:
        LOGGER.error('Error adding %r %r', user, password)
        LOGGER.debug('%s', data)
开发者ID:Gifts,项目名称:PhdaysSnatch,代码行数:12,代码来源:misc.py

示例7: do_otp

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
    def do_otp(self, obj):
        data = self._pre_otp(obj)
        if data is False:
            return False

        step3 = urllib2.Request('http://{0}/transaction.php'.format(TARGET_HOST),
            urllib.urlencode({
                'step': 'step3'
            })
        )
        step4 = urllib2.Request('http://{0}/transaction.php'.format(TARGET_HOST),
            urllib.urlencode({
                'step': 'step4'
            })
        )
        # Case:
        # 1) No otp
        if 'Commit transaction.' in data:
            LOGGER.info('No otp')
            data = my_url_open(obj.opener, step3)
        # 2) SmartCard otp
        elif 'One-time password:' in data:
            LOGGER.info('Smart card otp')

            data = my_url_open(obj.opener, step4)
        # 3) Brute otp
        elif 'One-time password (#' in data:
            tmp_ticket = RE_TICKET.search(data)
            if not tmp_ticket:
                return False
            tmp_ticket = tmp_ticket.group(1)
            step_OTP1 = urllib2.Request('http://{0}/transaction.php'.format(TARGET_HOST),
                urllib.urlencode({
                    'step': 'step3',
                    'OTP': obj.gen_otp(tmp_ticket, 2)
                })
            )
            step_OTP2 = urllib2.Request('http://{0}/transaction.php'.format(TARGET_HOST),
                urllib.urlencode({
                    'step': 'step3',
                    'OTP': obj.gen_otp(tmp_ticket, 3)
                })
            )
            data = my_url_open(obj.opener, step_OTP1)
            data += my_url_open(obj.opener, step_OTP2)
            data = my_url_open(obj.opener, step4)
        else:
            LOGGER.error('Bad transaction page: ')
            LOGGER.debug('%r', data)
        result = 'Transaction committed!' in data
        if result:
            LOGGER.info('Transaction from: %s', obj.number)
        return result
开发者ID:Gifts,项目名称:PhdaysSnatch,代码行数:55,代码来源:misc.py

示例8: run

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
    def run(self):
        LOGGER.info('Start stealer')
        while 1:
            try:
                obj = GOOD.get(timeout=2)
            except Exception as e:
                LOGGER.error('Unknown error in Stealer')
                continue
            if FORCE_STEAL:
                self.do_otp(obj)

            CHANGE.put(obj)
            GOOD.task_done()
开发者ID:Gifts,项目名称:PhdaysSnatch,代码行数:15,代码来源:main.py

示例9: postdata

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def postdata(self, **kw):
     try:
         data = kw['data']
     except:
         return None
     self.socket.sendall(json.dumps({'action': 'postdata', 'data': data})+ '\r\n')
     res = self.socket.recv(1024)
     r = json.loads(res, object_hook=_obj_hook)
     if hasattr(r, 'error'):
         LOGGER.error(r.error)
         return None
     else:
         return r.status
开发者ID:lijiahong,项目名称:WeMining,代码行数:15,代码来源:SoupSpider.py

示例10: target_travel

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def target_travel(self, ts, uid=None):
     if not uid:
         return None
     if uid in self.black_list:
         return None
     url = 'http://weibo.cn/u/'+uid
     current_page = 1
     home_page_soup = BeautifulSoup(self.client.urlopen(url+'?page=1'))
     try:
         name, verified, gender, location, desc, tags = self._travel_info(uid)
         print 'target spider %d searching uid: %s name: %s...' % (self.num, uid, name)
     except Exception, e:
         LOGGER.error('User %s Info Page Error:%s' % (uid, e))
         return None
开发者ID:lijiahong,项目名称:WeMining,代码行数:16,代码来源:SoupSpider.py

示例11: run

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def run(self):
     LOGGER.info('Run numeric login-password generator')
     for user in self.users_list:
         account_password_queue.put((user, sha1('{0}|hekked'.format(user)).hexdigest()))
         RECOVER.put(str(user))
         for password in self.passwords_list:
             if user in known_users:
                 break
             LOGGER.debug('Add in queue: %s:%s', user, password)
             while 1:
                 try:
                     account_password_queue.put((user, password), block=1, timeout=1)
                     break
                 except Queue.Full:
                     LOGGER.error('account_password queue full!')
                     pass
开发者ID:Gifts,项目名称:PhdaysSnatch,代码行数:18,代码来源:generators.py

示例12: spider

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
 def spider(self):
     while True:
         if not self.uid_queue.empty():
             try:
                 uid = self.uid_queue.get()
                 print 'searching user %s follows...' % uid
                 total_page, people_list = self.travel_follow(uid)
                 if len(people_list):
                     self.db.friendships.save({'_id': uid,
                           'follow_list': people_list,
                           'pages': total_page,
                           'last_modify': int(time.time())
                         })
                 else:
                     print 'no update for %s.' % uid
             except Exception, e:
                 LOGGER.error('User %s Follow Page Error: %s' % (uid, e))
         else:
             print 'uid queue empty'
             time.sleep(2)
开发者ID:lijiahong,项目名称:WeMining,代码行数:22,代码来源:friendship.py

示例13: main

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
def main():
    global uid_queue
    global data_queue
    db = getDB()
    dct = DataConsumerThread(db=db, data_queue=data_queue, uid_queue=uid_queue)
    dct.setDaemon(True)
    dct.start()
    users = db.users.find({'last_modify': 0})
    user_num = users.count()
    print '%s users will push to uid queue...' % user_num
    for user in users:
        uid = int(user['_id'])
        uid_queue.add(uid)
    print 'push ok.'
    server = eventlet.listen((HOST, PORT))
    pool = eventlet.GreenPool()
    while True:
        try:
            new_sock, address = server.accept()
            pool.spawn_n(handle, new_sock.makefile('rw'), address)
        except (SystemExit, KeyboardInterrupt):
            break
        except Exception, e:
            LOGGER.error('Server Error: %s' % e)
开发者ID:lijiahong,项目名称:WeMining,代码行数:26,代码来源:SpiderServer.py

示例14: send

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
def send(portal, message, subject, recipients=[]):
    """Send an email.

    this is taken from Products.eXtremeManagement
    """
    # Weed out any empty strings.
    recipients = [r for r in recipients if r]
    if not recipients:
        LOGGER.warn("No recipients to send the mail to, not sending.")
        return

    charset = portal.getProperty('email_charset', 'ISO-8859-1')
    # Header class is smart enough to try US-ASCII, then the charset we
    # provide, then fall back to UTF-8.
    header_charset = charset

    # We must choose the body charset manually
    for body_charset in 'US-ASCII', charset, 'UTF-8':
        try:
            message = message.encode(body_charset)
        except UnicodeError:
            pass
        else:
            break
        
    # Get the 'From' address.
    registry = getUtility(IRegistry)
    sender_name = registry.get('plone.email_from_name')
    sender_addr = registry.get('plone.email_from_address')

    # We must always pass Unicode strings to Header, otherwise it will
    # use RFC 2047 encoding even on plain ASCII strings.
    sender_name = str(Header(safe_unicode(sender_name), header_charset))
    # Make sure email addresses do not contain non-ASCII characters
    sender_addr = sender_addr.encode('ascii')
    email_from = formataddr((sender_name, sender_addr))

    formatted_recipients = []
    for recipient in recipients:
        # Split real name (which is optional) and email address parts
        recipient_name, recipient_addr = parseaddr(recipient)
        recipient_name = str(Header(safe_unicode(recipient_name),
                                    header_charset))
        recipient_addr = recipient_addr.encode('ascii')
        formatted = formataddr((recipient_name, recipient_addr))
        formatted_recipients.append(formatted)
    email_to = ', '.join(formatted_recipients)

    # Make the subject a nice header
    subject = Header(safe_unicode(subject), header_charset)

    # Create the message ('plain' stands for Content-Type: text/plain)

    # plone4 should use 'text/plain' according to the docs, but this should work for us
    # http://plone.org/documentation/manual/upgrade-guide/version/upgrading-plone-3-x-to-4.0/updating-add-on-products-for-plone-4.0/mailhost.securesend-is-now-deprecated-use-send-instead/
    msg = MIMEText(message, 'html', body_charset)
    msg['From'] = email_from
    msg['To'] = email_to
    msg['Subject'] = subject
    msg = msg.as_string()

    # Finally send it out.
    mailhost = getToolByName(portal, 'MailHost')
    try:
        LOGGER.info("Begin sending email to %r " % formatted_recipients)
        LOGGER.info("Subject: %s " % subject)
        mailhost.send(msg)
    except gaierror, exc:
        LOGGER.error("Failed sending email to %r" % formatted_recipients)
        LOGGER.error("Reason: %s: %r" % (exc.__class__.__name__, str(exc)))
开发者ID:,项目名称:,代码行数:72,代码来源:

示例15: ConfigParser

# 需要导入模块: from config import LOGGER [as 别名]
# 或者: from config.LOGGER import error [as 别名]
from ConfigParser import ConfigParser
from config import LOGGER, CONFIG_FILE

config = ConfigParser()
config.read(CONFIG_FILE)
try:
    HOST = config.get('server', 'host')
    PORT =config.getint('server', 'port')
    THREAD_NUM = config.getint('number', 'thread')
    black_str = config.get('user', 'blacklist')
    if black_str:
        BLACK_UIDS = black_str.split(',')
    else:
        BLACK_UIDS = []
except:
    LOGGER.error('Config File Error!')
    exit()


class WeiboURL(object):
    '''根据地址获得微博中的网页 线程安全
    '''
    def __init__(self):
        user_agent = '''Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us)
                AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4
                Mobile/7B334b Safari/531.21.10'''

        cookie_str = load_cookies()
        self.headers = {'User-Agent': user_agent,
                  'Cookie': cookie_str}
        self.http_pool = urllib3.connection_from_url("http://weibo.cn", timeout=5, maxsize=THREAD_NUM*2, headers=self.headers)
开发者ID:lijiahong,项目名称:WeMining,代码行数:33,代码来源:SoupSpider.py


注:本文中的config.LOGGER.error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。