當前位置: 首頁>>代碼示例>>Python>>正文


Python logger.exception方法代碼示例

本文整理匯總了Python中logger.exception方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.exception方法的具體用法?Python logger.exception怎麽用?Python logger.exception使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在logger的用法示例。


在下文中一共展示了logger.exception方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def init(config):
	try:
		global __connection_pool
		__connection_pool = PooledDB(
				creator=MySQLdb,
				mincached=1,
				maxcached=20,
				host=config.db_host,
				port=config.db_port,
				user=config.db_user,
				passwd=config.db_pass,
				db=config.db_database,
				use_unicode=False,
				charset="utf8",
				cursorclass=DictCursor)

		return True
	except Exception as e:
		logger.exception(e,"Mysql數據庫初始化失敗:host=%s,user=%s,pass=%s,db=%s",config.db_host,config.db_user,config.db_pass,config.db_database)
		return False 
開發者ID:newsettle,項目名稱:ns4_chatbot,代碼行數:22,代碼來源:db_helper.py

示例2: from_object

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def from_object(self, obj):
        """Populate application from object"""
        loaded_obj = obj

        if isinstance(obj, str):
            try:
                loaded_obj = json.loads(obj)
            except Exception as exception:
                logger.exception("Problem loading json apps object", exception,
                                 err_message=exception.message,
                                 trace=json.dumps(traceback.format_exc()))
                sys.exit(1)

        for key, value in loaded_obj.items():
            self.__dict__[key] = value

        if self.commit_log:
            for key, value in consts.RENAME_COMMIT_LOG_KEYS.items():
                if key in self.commit_log:
                    self.commit_log[value] = self.commit_log.pop(key, None)

        return self 
開發者ID:Bridgewater,項目名稱:appetite,代碼行數:24,代碼來源:appetite_core.py

示例3: send

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def send(apiUrl,data,method=None):
    logger.debug("調用內部係統[%s],data[%r]",apiUrl,data)
    try:
        data_json = json.dumps(data)
        headers = {'Content-Type': 'application/json'} # 設置數據為json格式,很重要
        request = urllib2.Request(url=apiUrl, headers=headers, data=data_json)
        if method is not None:
            request.get_method = method

        response = urllib2.urlopen(request)
        result = {'code':response.getcode(),'content':response.read()}
        logger.debug("調用[%s]返回結果:%r",apiUrl,result)
        return result
    except Exception as e:
        #traceback.print_stack()
        logger.exception(e,"調用內部係統[%s],data[%r],發生錯誤[%r]", apiUrl, data,e)
        return None 
開發者ID:newsettle,項目名稱:ns4_chatbot,代碼行數:19,代碼來源:web_client.py

示例4: ReadStatistics

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def ReadStatistics(self):
    if not self.server.settings.get('statsport'):
      return None
    try:
      response=requests.get("http://%s:%d" % (self.server.settings['host'], self.server.settings['statsport']), timeout=self.server.settings.get('timeout', 1.))
      response.raise_for_status()
      txt=response.text
    except Exception as _e:
      return None

    try:
      root=xmltree.fromstring(txt)
    except Exception as _e:
      import logger, adm, time
      fname="%s/xml-%s_%s.xml" % (adm.loaddir, self.server.settings['host'], time.strftime("%Y%m%d%H%M%S", time.localtime(time.time())))
      logger.exception("Error parsing BIND response %s", fname)
      f=open(fname, "w")
      f.write(txt)
      f.close() 
      return None
    return root 
開發者ID:andreas-p,項目名稱:admin4,代碼行數:23,代碼來源:_dns.py

示例5: process_queue

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def process_queue():
    queue = plexpy.NOTIFY_QUEUE
    while True:
        params = queue.get()
        
        if params is None:
            break
        elif params:
            try:
                if 'newsletter' in params:
                    notify_newsletter(**params)
                elif 'notification' in params:
                    notify(**params)
                else:
                    add_notifier_each(**params)
            except Exception as e:
                logger.exception("Tautulli NotificationHandler :: Notification thread exception: %s" % e)

        queue.task_done()

    logger.info("Tautulli NotificationHandler :: Notification thread exiting...") 
開發者ID:Tautulli,項目名稱:Tautulli,代碼行數:23,代碼來源:notification_handler.py

示例6: create_path

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def create_path(path, is_dir=False):
    """Create Path"""
    try:
        split_path = path if is_dir else os.path.split(path)[0]
        if not os.path.exists(split_path):
            os.makedirs(split_path)
    except Exception as e:
        logger.exception("Problem creating folder", e, path=path)
        return False
    return True 
開發者ID:Bridgewater,項目名稱:appetite,代碼行數:12,代碼來源:helpers.py

示例7: delete_path

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def delete_path(path):
    """Delete path including content"""
    try:
        if os.path.exists(path):
            shutil.rmtree(path)
    except Exception as e:
        logger.exception("Problem deleting folder", e, path=path)
        return False
    return True 
開發者ID:Bridgewater,項目名稱:appetite,代碼行數:11,代碼來源:helpers.py

示例8: _aggregate_batch

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def _aggregate_batch(data_holder, use_list=False):
        size = len(data_holder[0])
        result = []
        for k in range(size):
            if use_list:
                result.append(
                    [x[k] for x in data_holder])
            else:
                dt = data_holder[0][k]
                if type(dt) in [int, bool]:
                    tp = 'int32'
                elif type(dt) == float:
                    tp = 'float32'
                else:
                    try:
                        tp = dt.dtype
                    except AttributeError:
                        raise TypeError("Unsupported type to batch: {}".format(type(dt)))
                try:
                    result.append(
                        np.asarray([x[k] for x in data_holder], dtype=tp))
                except Exception as e:  # noqa
                    logger.exception("Cannot batch data. Perhaps they are of inconsistent shape?")
                    if isinstance(dt, np.ndarray):
                        s = pprint.pformat([x[k].shape for x in data_holder])
                        logger.error("Shape of all arrays to be batched: " + s)
                    try:
                        # open an ipython shell if possible
                        import IPython as IP; IP.embed()    # noqa
                    except ImportError:
                        pass
        return result 
開發者ID:Guanghan,項目名稱:lighttrack,代碼行數:34,代碼來源:data_provider.py

示例9: send_sms

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def send_sms(content,mobile_num = None):
    # logger.debug("調用內部係統[%s],data[%r]",apiUrl,data)

    try:

        data = {"merchId": config.sms_merchId,
                "orderId": config.sms_orderId,
                "smsTypeNo": config.sms_smsTypeNo,
                "mobile": config.admin_mobile,
                "stp_content": str(content)}
        data_urlencode = urllib.urlencode(data)
        request = urllib2.Request(url=config.sms_server, data=data_urlencode)
        response = urllib2.urlopen(request,timeout=3)
        result = {'code': response.getcode(), 'content':json.loads(response.read())}
        if result['content']['retCode'] == '0000':
            logger.info("短信發送成功")
        else:
            logger.info("短信發送失敗:狀態[%s],原因[%s]",result['content']['retCode'],result['content']['retInfo'])
        # 返回'content' 的內容
        # {
        #     "retCode": "0000",
        #     "retInfo": "提交成功",
        #     "data": {}
        # }
        return result['content']
    except Exception as e:
        #這裏不能用logger.error或者logger.exception,否則,容易形成死循環
        logger.info("短信發送失敗:content=%s",content)
        logger.info("短信失敗原因:%s", str(e))
        return None 
開發者ID:newsettle,項目名稱:ns4_chatbot,代碼行數:32,代碼來源:common.py

示例10: run

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def run(self):
    update=OnlineUpdate()
    if update.IsValid():
      adm.updateInfo=update
      if update.UpdateAvailable():
        wx.CallAfter(self.frame.OnUpdate)
    elif update.exception:
      wx.CallAfter(wx.MessageBox,
                   xlt("Connection error while trying to retrieve update information from the update server.\nCheck network connectivity and proxy settings!"), 
                   xlt("Communication error"), wx.ICON_EXCLAMATION) 
開發者ID:andreas-p,項目名稱:admin4,代碼行數:12,代碼來源:Update.py

示例11: __init__

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def __init__(self):
    self.info=None
    self.message=None
    self.exception=None
    
    if not Crypto:
      self.message=xlt("No Crypto lib available.")
      return
    modsUsed={}
    for server in adm.config.getServers():
      mod=server.split('/')[0]
      modsUsed[mod] = modsUsed.get(mod, 0) +1
      
    try:
      info = "?ver=%s&rev=%s&mods=%s" % (admVersion.version, admVersion.revDate.replace(' ', '_'), ",".join(modsUsed.keys()))
      response=HttpGet("https://www.admin4.org/update.xml%s" % info)
      xmlText=response.text
      sigres=HttpGet("https://www.admin4.org/update.sign")
      signature=sigres.content
      
    except Exception as ex:
      self.exception = ex
      self.message=xlt("Online update check failed.\n\nError reported:\n  %s") % str(ex)
      return

    if True: # we want to check the signature
      f=open(os.path.join(adm.loaddir, 'admin4.pubkey'))
      keyBytes=f.read()
      f.close()

      # https://www.dlitz.net/software/pycrypto/api/current/Crypto-module.html
      pubkey=Crypto.PublicKey.RSA.importKey(keyBytes)
      verifier = Crypto.Signature.PKCS1_v1_5.new(pubkey)
      hash=Crypto.Hash.SHA.new(xmlText)

      if not verifier.verify(hash, signature):
        self.message = xlt("Online update check failed:\nupdate.xml cryptographic signature not valid.")
        return
    
    self.info=XmlDocument.parse(xmlText)
    adm.config.Write('LastUpdateCheck', time.time()) 
開發者ID:andreas-p,項目名稱:admin4,代碼行數:43,代碼來源:Update.py

示例12: DoInstall

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def DoInstall(self, tmpDir, source):
    if not os.path.isdir(source):
      try:
        zip=zipfile.ZipFile(source)
        zipDir=zip.namelist()[0]
        zip.extractall(tmpDir)
        zip.close()
      except Exception as _e:
        self.ModuleInfo = xlt("Error extracting\n%s") % source
        logger.exception("Error extracting %s", source)
        return False

      source = os.path.join(tmpDir, zipDir)

    if self.modname == "Core":
      destination=adm.loaddir
    else:
      destination=os.path.join(adm.loaddir, self.modid)
      
    copytree(source, destination)
    try: shutil.rmtree(tmpDir)
    except: pass
    
    if self.modname == "Core":
      try:
        # Make start file executable for unpackaged files
        startFile=sys.argv[0] # usually admin4.py
        st=os.stat(startFile)
        os.chmod(startFile, st.st_mode | stat.S_IXUSR|stat.S_IXGRP|stat.S_IXOTH)
      except: pass
    return True 
開發者ID:andreas-p,項目名稱:admin4,代碼行數:33,代碼來源:Update.py

示例13: send_email

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def send_email(email,subject,content,attach_file_path=None):

    if not email: email = config.admin_email

    msg = MIMEMultipart()
    msg['Subject'] = subject
    msg['From'] = config.email_user
    msg['To'] = email

    to_users = email.split(',')

    # 構造文字內容
    text_plain = MIMEText(content, 'plain', 'utf-8')
    msg.attach(text_plain)

    # jpg類型附件
    if attach_file_path is not None:
        part = MIMEApplication(open(attach_file_path, 'rb').read())
        part.add_header('Content-Disposition', 'attachment', filename=attach_file_path)
        msg.attach(part)

    try:

        if config.email_SSL:
            s = smtplib.SMTP_SSL(config.email_server, config.email_port)  # 郵件服務器及端口號
        else:
            s = smtplib.SMTP(config.email_server, config.email_port)  # 郵件服務器及端口號
        s.login(config.email_user, config.email_passwd)
        s.sendmail(config.email_user,to_users, msg.as_string())
        logger.debug("郵件發送完畢:title=%s,content=%s", subject, content)
        s.quit()
        return True
    except Exception as e:
        #這裏不能用logger.error或者logger.exception,否則,容易形成死循環
        logger.info("郵件發送失敗:title=%s,content=%s",subject,content)
        logger.info("郵件失敗原因:%s", str(e))
        logger.info("郵件配置信息:server=%s,user=%s,pass=%s,to=%s",
                    config.email_server,
                    config.email_user,
                    config.email_passwd,
                    config.admin_email)
        return False 
開發者ID:newsettle,項目名稱:ns4_chatbot,代碼行數:44,代碼來源:common.py

示例14: process

# 需要導入模塊: import logger [as 別名]
# 或者: from logger import exception [as 別名]
def process(opcode, data):
    if opcode not in opcode_data:
        return False

    try:
        data = data.decode('utf-8')
        logger.websocket_debug(data)
        info = json.loads(data)
    except Exception as e:
        logger.warn("Tautulli WebSocket :: Error decoding message from websocket: %s" % e)
        logger.websocket_error(data)
        return False

    info = info.get('NotificationContainer', info)
    info_type = info.get('type')

    if not info_type:
        return False

    if info_type == 'playing':
        time_line = info.get('PlaySessionStateNotification', info.get('_children', {}))

        if not time_line:
            logger.debug("Tautulli WebSocket :: Session found but unable to get timeline data.")
            return False

        try:
            activity = activity_handler.ActivityHandler(timeline=time_line[0])
            activity.process()
        except Exception as e:
            logger.exception("Tautulli WebSocket :: Failed to process session data: %s." % e)

    if info_type == 'timeline':
        time_line = info.get('TimelineEntry', info.get('_children', {}))

        if not time_line:
            logger.debug("Tautulli WebSocket :: Timeline event found but unable to get timeline data.")
            return False

        try:
            activity = activity_handler.TimelineHandler(timeline=time_line[0])
            activity.process()
        except Exception as e:
            logger.exception("Tautulli WebSocket :: Failed to process timeline data: %s." % e)

    return True 
開發者ID:Tautulli,項目名稱:Tautulli,代碼行數:48,代碼來源:web_socket.py


注:本文中的logger.exception方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。