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


Python log.log_error函数代码示例

本文整理汇总了Python中tipbot.log.log_error函数的典型用法代码示例。如果您正苦于以下问题:Python log_error函数的具体用法?Python log_error怎么用?Python log_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: Bookie

def Bookie(link,cmd):
  identity=link.identity()

  name = GetParam(cmd,1)
  if not name:
    link.send('usage: !bookie <name> <outcome1> <outcome2> [<outcome3>...]')
    return
  outcomes = cmd[2:]
  if len(outcomes) < 2:
    link.send('usage: !bookie <name> <outcome1> <outcome2> [<outcome3>...]')
    return

  book_index=long(redis_get('bookie:last_book') or 0)
  book_index += 1
  tname = "bookie:%d" % book_index

  log_info('%s opens book #%d for %s, with outcomes %s' % (identity, book_index, name, str(outcomes)))
  try:
    p = redis_pipeline()
    p.hset(tname,'name',name)
    for o in outcomes:
      p.sadd(tname+':outcomes',o)
    p.hset('bookie:active',book_index,name)
    redis_set('bookie:last_book',book_index)
    p.execute()
  except Exception,e:
    log_error('Bookie: Failed to register book for %s with outcomes %s: %s' % (name, str(outcomes), str(e)))
    link.send('Failed to create book')
    return
开发者ID:clintar,项目名称:tippero,代码行数:29,代码来源:bookie.py

示例2: ValidateDNSSEC

def ValidateDNSSEC(address):
  log_info('Validating DNSSEC for %s' % address)
  try:
    resolver = dns.resolver.get_default_resolver()
    ns = resolver.nameservers[0]
    parts = address.split('.')
    for i in xrange(len(parts),0,-1):
      subpart = '.'.join(parts[i-1:])
      query = dns.message.make_query(subpart,dns.rdatatype.NS)
      response = dns.query.udp(query,ns,1)
      if response.rcode() != dns.rcode.NOERROR:
        return False
      if len(response.authority) > 0:
        rrset = response.authority[0]
      else:
        rrset = response.answer[0]
      rr = rrset[0]
      if rr.rdtype == dns.rdatatype.SOA:
        continue
      query = dns.message.make_query(subpart,dns.rdatatype.DNSKEY,want_dnssec=True)
      response = dns.query.udp(query,ns,1)
      if response.rcode() != 0:
        return False
      answer = response.answer
      if len(answer) != 2:
        return False
      name = dns.name.from_text(subpart)
      dns.dnssec.validate(answer[0],answer[1],{name:answer[0]})
      return True
  except Exception,e:
    log_error('Failed to validate DNSSEC for %s: %s' % (address, str(e)))
    return False
开发者ID:clintar,项目名称:tippero,代码行数:32,代码来源:withdraw.py

示例3: _connect

  def _connect(self,host,port,login,password,delay):
    self.host=host
    self.port=port
    self.login=login
    self.password=password
    self.line_delay=delay

    log_info('Connecting to IRC at %s:%u' % (host, port))
    self.last_send_time=0
    self.last_ping_time = time.time()
    self.quitting = False
    self.buffered_data = ""
    self.userstable=dict()
    self.registered_users=set()
    try:
      self.irc = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
      if self.use_ssl:
        try:
          raise RuntimeError('')
          self.irc_ssl_context = ssl.create_default_context()
          self.sslirc = self.irc_ssl_context.wrap_socket(self.irc, host)
          self.sslirc.connect ( ( host, port ) )
        except Exception,e:
          log_warn('Failed to create SSL context, using fallback code: %s' % str(e))
          self.irc.connect ( ( host, port ) )
          self.sslirc = socket.ssl(self.irc)
    except Exception, e:
      log_error( 'Error initializing IRC: %s' % str(e))
      return False
开发者ID:clintar,项目名称:tippero,代码行数:29,代码来源:irc.py

示例4: GetPaymentID

def GetPaymentID(link):
  salt="2u3g55bkwrui32fi3g4bGR$j5g4ugnujb-"+coinspecs.name+"-";
  p = hashlib.sha256(salt+link.identity()).hexdigest();
  try:
    redis_hset("paymentid",p,link.identity())
  except Exception,e:
    log_error('GetPaymentID: failed to set payment ID for %s to redis: %s' % (link.identity(),str(e)))
开发者ID:clintar,项目名称:tippero,代码行数:7,代码来源:utils.py

示例5: run

 def run(self):
   while not self.stop:
     try:
       self._check()
     except Exception,e:
       log_error('Exception in TwitterNetwork:_check: %s' % str(e))
     time.sleep(1)
开发者ID:clintar,项目名称:tippero,代码行数:7,代码来源:twitter.py

示例6: _parse_tweet

  def _parse_tweet(self,msg):
    if msg.user.screen_name.lower() == self.login.lower() and not force_parse_self:
      log_log('Ignoring tweet from self')
      return

    log_info('Twitter: parsing tweet from %s: %s' % (msg.user.screen_name,msg.text))

    # twitter special: +x means tip the user mentioned with a @
    for line in msg.text.split('\n'):
      line=line.lower()
      line=line.replace(self.keyword,'',1).strip()
      log_log('After removal: %s' % line)
      if re.match(username_regexp+"[ \t]*"+amount_regexp,line) or re.match(amount_regexp+"[ \t]*"+username_regexp,line):
        link=Link(self,User(self,msg.user.screen_name),None,msg)
        match=re.search(username_regexp,line)
        if not match:
          continue
        target=match.group(0)
        match=re.search(amount_regexp,line.replace(target,'').strip())
        if not match:
          continue
        amount=match.group(0)
        if self.on_command:
          try:
            synthetic_cmd=['tip',target.replace('@','').strip(),amount.replace('+','').strip()]
            log_log('Running synthetic command: %s' % (str(synthetic_cmd)))
            self.on_command(link,synthetic_cmd)
          except Exception,e:
            log_error('Failed to tip %s: %s' % (target,str(e)))
开发者ID:clintar,项目名称:tippero,代码行数:29,代码来源:twitter.py

示例7: _post_next_reply

  def _post_next_reply(self):
    data=redis_lindex('twitter:replies',0)
    if not data:
      return False
    parts=data.split(':',2)
    mtype=parts[0]
    data=parts[1]
    text=parts[2]

    try:
      if mtype == 'g':
        log_info('call: update_status(%s,%s)' % (str(text),str(data)))
        self.twitter.update_status(status=text,in_reply_to_status_id=data)
      elif mtype == 'u':
        log_info('call: send_direct_message(%s,%s)' % (str(data),str(text)))
        self.twitter.send_direct_message(user=data,text=text)
      else:
        log_error('Invalid reply type: %s' % str(mtype))
      redis_lpop('twitter:replies')
    except Exception,e:
      log_error('Failed to send reply: %s' % str(e))
      redis_lpop('twitter:replies')
      return True

      return False
开发者ID:clintar,项目名称:tippero,代码行数:25,代码来源:twitter.py

示例8: connect

  def connect(self):
    if self.thread:
      return False
    try:
      cfg=config.network_config[self.name]
      self.login=cfg['login']
      password=GetPassword(self.name)
      self.subreddits=cfg['subreddits']
      user_agent=cfg['user_agent']
      self.update_period=cfg['update_period']
      self.load_limit=cfg['load_limit']
      self.keyword=cfg['keyword']
      self.use_unread_api=cfg['use_unread_api']
      self.cache_timeout=cfg['cache_timeout']

      self.reddit=praw.Reddit(user_agent=user_agent,cache_timeout=self.cache_timeout)
      self.reddit.login(self.login,password)
      self.items_cache=dict()

      self.stop = False
      self.thread = threading.Thread(target=self.run)
      self.thread.start()
      self.logged_in=True

    except Exception,e:
      log_error('Failed to login to reddit: %s' % str(e))
      return False
开发者ID:clintar,项目名称:tippero,代码行数:27,代码来源:reddit.py

示例9: PerformTip

def PerformTip(link,whoid,units):
  identity=link.identity()
  try:
    account = GetAccount(identity)
    who_account = GetAccount(whoid)
    balance = redis_hget("balances",account)
    if balance == None:
      balance = 0
    balance=long(balance)
    if units > balance:
      link.send("You only have %s" % (AmountToString(balance)))
      return
    log_info('Tip: %s tipping %s %u units, with balance %u' % (identity, whoid, units, balance))
    try:
      p = redis_pipeline()
      p.incrby("tips_total_count",1);
      p.incrby("tips_total_amount",units);
      p.hincrby("tips_count",identity,1);
      p.hincrby("tips_amount",identity,units);
      p.hincrby("balances",account,-units);
      p.hincrby("balances",who_account,units)
      p.execute()
      if units < coinspecs.atomic_units:
        link.send("%s has tipped %s %s (%.16g %s)" % (NickFromIdentity(identity), NickFromIdentity(whoid), AmountToString(units), float(units) / coinspecs.atomic_units, coinspecs.name))
      else:
        link.send("%s has tipped %s %s" % (NickFromIdentity(identity), NickFromIdentity(whoid), AmountToString(units)))
    except Exception, e:
      log_error("Tip: Error updating redis: %s" % str(e))
      link.send("An error occured")
      return
  except Exception, e:
    log_error('Tip: exception: %s' % str(e))
    link.send("An error has occured")
开发者ID:clintar,项目名称:tippero,代码行数:33,代码来源:tipping.py

示例10: CompatibilityCheck

def CompatibilityCheck():
  try:
    r = redis.Redis()
    if not r.pipeline: raise RuntimeError('pipeline call not found')
    p = r.pipeline()
    if not p.exists: raise RuntimeError('exists call not found')
    if not p.get: raise RuntimeError('get call not found')
    if not p.set: raise RuntimeError('set call not found')
    if not p.hexists: raise RuntimeError('hexists call not found')
    if not p.hget: raise RuntimeError('hget call not found')
    if not p.hgetall: raise RuntimeError('hgetall call not found')
    if not p.hset: raise RuntimeError('hset call not found')
    if not p.hincrby: raise RuntimeError('hincrby call not found')
    if not p.hdel: raise RuntimeError('hdel call not found')
    if not p.incrby: raise RuntimeError('incrby call not found')
    if not p.sadd: raise RuntimeError('sadd call not found')
    if not p.smembers: raise RuntimeError('smembers call not found')
    if not p.sismember: raise RuntimeError('sismember call not found')
    if not p.rpush: raise RuntimeError('rpush call not found')
    if not p.lpop: raise RuntimeError('lpop call not found')
    if not p.llen: raise RuntimeError('llen call not found')
    if not p.lindex: raise RuntimeError('lindex call not found')
    if not p.lset: raise RuntimeError('lset call not found')
    if not p.zincrby: raise RuntimeError('zincrby call not found')
    if not p.zscore: raise RuntimeError('zscore call not found')
    if not p.zrangebylex: raise RuntimeError('zrangebylex call not found')
    if not p.keys: raise RuntimeError('keys call not found')
    if not p.execute: raise RuntimeError('execute call not found')
    if not p.delete: raise RuntimeError('delete call not found')
  except Exception,e:
    log_error('Error checking redis compatibility: %s' % str(e))
    exit(1)
开发者ID:clintar,项目名称:tippero,代码行数:32,代码来源:redisdb.py

示例11: GetHeight

def GetHeight(link,cmd):
  log_info('GetHeight: %s wants to know block height' % str(link))
  try:
    j = SendDaemonHTMLCommand("getheight")
  except Exception,e:
    log_error('GetHeight: error: %s' % str(e))
    link.send("An error has occured")
    return
开发者ID:clintar,项目名称:tippero,代码行数:8,代码来源:tipbot.py

示例12: get_last_active_time

 def get_last_active_time(self,nick,chan):
   if not chan in self.userstable:
     log_error("IRCNetwork:get_last_active_time: channel %s not found in users table" % chan)
     return None
   if not nick in self.userstable[chan]:
     log_error("IRCNetwork:get_last_active_time: %s not found in channel %s's users table" % (nick, chan))
     return None
   return self.userstable[chan][nick]
开发者ID:clintar,项目名称:tippero,代码行数:8,代码来源:irc.py

示例13: FairCheck

def FairCheck(link,cmd):
  identity=link.identity()
  try:
    seed = GetServerSeed(link,'blackjack')
  except Exception,e:
    log_error('Failed to get server seed for %s: %s' % (identity,str(e)))
    link.send('An error has occured')
    return
开发者ID:clintar,项目名称:tippero,代码行数:8,代码来源:blackjack.py

示例14: Seeds

def Seeds(link,cmd):
  identity=link.identity()
  try:
    sh = GetServerSeedHash(link,'dice')
    ps = GetPlayerSeed(link,'dice')
  except Exception,e:
    log_error('Failed to get server seed for %s: %s' % (identity,str(e)))
    link.send('An error has occured')
    return
开发者ID:clintar,项目名称:tippero,代码行数:9,代码来源:dice.py

示例15: _intern

 def _intern(self,contents):
   base=str(time.time())+":"+str(getrandbits(128))+":"
   for n in range(10000):
     filename=hashlib.sha256(base+str(n)).hexdigest()[:self.fs_hash_length]
     split_path=self._check_and_create(filename,contents)
     if split_path:
       return split_path
   log_error('Failed to intern contents')
   return None
开发者ID:clintar,项目名称:tippero,代码行数:9,代码来源:twitter.py


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