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


Python PLOG.trace方法代碼示例

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


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

示例1: heartbeatCheck

# 需要導入模塊: from pysmartac.log import PLOG [as 別名]
# 或者: from pysmartac.log.PLOG import trace [as 別名]
 def heartbeatCheck(self):
     if self.isTimeOut():
         PLOG.debug("%s websocket timeout,disconnect it"%self.wsname) 
         self.close()
         WSManager.RemoveWebSocket(self.wsname)
     else:
         PLOG.trace("send ping")
         self.ping("ping")
開發者ID:zhangqiaoli,項目名稱:pythonTool,代碼行數:10,代碼來源:PagejumpDemo.py

示例2: querysql

# 需要導入模塊: from pysmartac.log import PLOG [as 別名]
# 或者: from pysmartac.log.PLOG import trace [as 別名]
def querysql(sqltext,dboperater=None,how = 0):
    resultls = []
    try:
        if dboperater == None:
            dboperater = DBOperater()
        if dboperater.conn == None:
            dboperater.createconnection(host=sadb.host,user=sadb.dbuser,passwd=sadb.dbpwd,dbname=sadb.dbname) #數據庫連接
        rowNum, result = dboperater.query(sqltext)
        PLOG.trace("%s query finish"%(sqltext))
        resultls = dboperater.fetch_queryresult(result,rowNum, how = how) 
    except MySQLdb.Error,e:
        PLOG.debug("Mysql Error %d: %s,sql=%s" %(e.args[0], e.args[1],sqltext)) 
        return None
開發者ID:zhangqiaoli,項目名稱:pythonTool,代碼行數:15,代碼來源:SAPeakDataPublic.py

示例3: CF

# 需要導入模塊: from pysmartac.log import PLOG [as 別名]
# 或者: from pysmartac.log.PLOG import trace [as 別名]
            items = []
            for p in self.programlist:
                items.append((p.name, p.status))
            fmt = '%-40s %9s'
            ret = '\n'.join([fmt % (x, '[%s]' % y) for x, y in items])
            PLOG.info("report runing status:\n%s" % ret)
        elif msg == "stop":
            pass
        return ret
class CF:
    pass
if __name__ == "__main__":
    conf = CF()
    conf.host = "127.0.0.1"
    conf.port = 24001
    PLOG.trace(assistant.SF("%s/log/ALS_$(Date8)_$(filenumber2).log" % (os.path.dirname(__file__))))
    PLOG.enableFilelog("%s/log/ALS_$(Date8)_$(filenumber2).log" % (os.path.dirname(__file__)))
    try:
        parentpid = os.getppid()
    except:
        print "no parent id!"
        sys.exit(1)
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    try:
        s.bind((conf.host, conf.port))
        s.settimeout(1)
    except Exception, e:
        print("綁定UDP端口失敗,Host=%s,Port=%d,err=%s" % (conf.host, conf.port, e))
        sys.exit(1)
    print ("Start listen UDP[%s:%d]..." % (conf.host, conf.port))
開發者ID:zhangqiaoli,項目名稱:pythonTool,代碼行數:33,代碼來源:alwayson_dog.py

示例4: on_pong

# 需要導入模塊: from pysmartac.log import PLOG [as 別名]
# 或者: from pysmartac.log.PLOG import trace [as 別名]
 def on_pong(self,data):
     PLOG.trace("receive pong")
     self.updateActiveTime()
開發者ID:zhangqiaoli,項目名稱:pythonTool,代碼行數:5,代碼來源:PagejumpDemo.py

示例5: on_message

# 需要導入模塊: from pysmartac.log import PLOG [as 別名]
# 或者: from pysmartac.log.PLOG import trace [as 別名]
 def on_message(self, message):
     PLOG.trace("receive msg %s"%message)
     self.updateActiveTime()
開發者ID:zhangqiaoli,項目名稱:pythonTool,代碼行數:5,代碼來源:PagejumpDemo.py

示例6: statisticsCurrentDayData

# 需要導入模塊: from pysmartac.log import PLOG [as 別名]
# 或者: from pysmartac.log.PLOG import trace [as 別名]
def statisticsCurrentDayData(daydate) :
    nextday = daydate+datetime.timedelta(days=1)
    startquerytime = daydate
    endquerytime = daydate+datetime.timedelta(hours=SAPeakDataPublic.st.queryunit)
    while endquerytime<=nextday:
        acctquerysql = "select acctinputoctets,acctoutputoctets,acctstarttime,acctstoptime,regionid from %s where acctstarttime>='%s' and acctstarttime<'%s'"%\
                   (SAPeakDataPublic.sadb.tablename,startquerytime.strftime('%Y-%m-%d %H:%M:%S'),endquerytime.strftime('%Y-%m-%d %H:%M:%S')) 
        PLOG.debug("sql=%s"%acctquerysql)
        startquerytime=endquerytime
        endquerytime=endquerytime+datetime.timedelta(hours=SAPeakDataPublic.st.queryunit)
        i = 0
        while i<SAPeakDataPublic.st.queryrepeattimes:            
            res = SAPeakDataPublic.querysql(acctquerysql)
            if res!=None:
                break
            else:
                i = i+1
        if i==3 or res==None:
            print("%s statistics data failed! db query appear error %d consecutive times,please execute again later!"%(daydate.strftime('%Y-%m-%d'),SAPeakDataPublic.st.queryrepeattimes))
            PLOG.info("%s statistics data failed! db query appear error %d consecutive times,please execute again later!"%(daydate.strftime('%Y-%m-%d'),SAPeakDataPublic.st.queryrepeattimes))
            return
        # 統計數據
        PLOG.trace("start statistics...")
        for row in res:
            if row[2] ==None or row[3] ==None or row[4] ==None:
                PLOG.warn("lack essential data!skip this data")
                continue          
            regionid = row[4]
            totalflow = 0
            if row[0]!=None:
                totalflow += row[0]
            if row[1]!=None:
                totalflow += row[1]
            if row[3].day > row[2].day:
                # 跨天
                endMinute = 23*60+59
            elif row[3].day < row[2].day:
                PLOG.info("stoptime day less than starttime day,invalid data,skip")
            else:
                endMinute = row[3].hour*60+row[3].minute 
            startMinute = row[2].hour*60+row[2].minute       
            #startMinute = datetime.datetime.strptime(row[2],'%Y-%m-%d %H:%M:%S')
            #endMinute = datetime.datetime.strptime(row[3],'%Y-%m-%d %H:%M:%S')
            totalMinute = endMinute-startMinute + 1
            if totalMinute <=0:
                PLOG.info("stoptime less than starttime,invalid data,skip")
                continue 
            if SAStopDefine.stopDc.stops.has_key(regionid):
                stop = SAStopDefine.stopDc.stops[regionid] 
                startindex = startMinute
                endindex = endMinute
                flowOneMinute = float(totalflow)/totalMinute/1024/1024
                index = startindex
                while index <= endindex:
                    stop.dayArray[index][0] += 1
                    stop.dayArray[index][1] += flowOneMinute
                    if stop.dayArray[index][0] > stop.peakonlinenum: 
                        stop.peakonlinenum = stop.dayArray[index][0]
                        stop.peakonlinetime = datetime.datetime(daydate.year,daydate.month,daydate.day,index/60,index%60)
                    if stop.dayArray[index][0] > stop.peakbandwidth:
                        stop.peakbandwidth = stop.dayArray[index][1]
                        stop.peakbandwidthtime = datetime.datetime(daydate.year,daydate.month,daydate.day,index/60,index%60)
                    index += 1
        PLOG.trace("statistics end")
    # 數據處理結束,輸出各站點峰值數據
    for stopid,stop in stopsCentor.stops.items():
        peakbandwidth = stop.peakbandwidth*8/60
        print("%s %s %d %.2f"%(daydate.strftime('%Y-%m-%d'),stop.name,stop.peakonlinenum,peakbandwidth))
        PLOG.debug("%s %s %d %.2f %s %s"%(daydate.strftime('%Y-%m-%d'),stop.name,stop.peakonlinenum,peakbandwidth,stop.peakonlinetime.strftime('%H:%M'),stop.peakbandwidthtime.strftime('%H:%M')))
開發者ID:zhangqiaoli,項目名稱:pythonTool,代碼行數:71,代碼來源:AcctPeakData.py


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