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


Python Library.getHomepath方法代码示例

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


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

示例1: loadMon

# 需要导入模块: import Library [as 别名]
# 或者: from Library import getHomepath [as 别名]
def loadMon(duration,interval,emulationID,emulationName,emuStartTime):
    
    HOMEPATH= Library.getHomepath()
    emulationName=str(emulationName)
    interval=int(interval)
    
    '''
    starting cpu monitoring in the loop
    '''
    iterationsNo=int(duration)/int(interval)
   
    try:
        f = open(HOMEPATH+"/logs/"+str(emulationID)+"-"+str(emulationName)+"-res"+"_"+str(emuStartTime)+".csv", 'a')    
        f.write(emulationName+";\nCountdown;Time;CPU(%);MEM(%);IOread(bytes);IOwrite(bytes);NET(bytes_sent)\n")
        #start time
        initTime=time.time()
        while iterationsNo !=0:
            CPU=str(psutil.cpu_percent(interval, False))
            #MEM=str(psutil.virtual_memory().percent)
            MEM=str(psutil.avail_virtmem())
            IOr=str(psutil.disk_io_counters().read_time)
            IOw=str(psutil.disk_io_counters().write_time)
            NET=str(psutil.network_io_counters(False).bytes_sent)

            #print (emulationName+";\nTime;CPU(%);MEM(%);IOread(bytes);IOwrite(bytes);NET(bytes_sent)\n"+str(time.time())+";"+CPU+";"+MEM+";"+IOr+";"+IOw+";"+NET)
            probeTime=time.time()-initTime
            timeStamp=dt.now()
            
            f.write(str(int(probeTime))+";"+str(timeStamp.strftime("%Y-%m-%d %H:%M:%S.%f"))+";"+CPU+";"+MEM+";"+IOr+";"+IOw+";"+NET+"\n")

            iterationsNo=iterationsNo-1
    except Exception,e:
        print "Unable to create log file\nError: ",e
开发者ID:cragusa,项目名称:cocoma,代码行数:35,代码来源:Logger.py

示例2: singleLogger

# 需要导入模块: import Library [as 别名]
# 或者: from Library import getHomepath [as 别名]
def singleLogger(elementName,level=None,filename=None):
    #file writing handler
    producer=Producer()
    HOMEPATH= Library.getHomepath()
    global emulationEndLogger
    emulationEndLogger=Library.loggerSet("Logger")

    def logLevelGet():
        
        LOG_LEVEL=logging.INFO
        
        LogLevel=Library.readLogLevel("coreloglevel")
        if LogLevel=="info":
            LOG_LEVEL=logging.INFO
        if LogLevel=="debug":
            LOG_LEVEL=logging.DEBUG
        else:
            LOG_LEVEL=logging.INFO
        
        
        return LOG_LEVEL

    if level==None:
        level=logLevelGet()
    
    fileLogger=logging.getLogger(elementName)
    fileLogger.setLevel(level)
    #we do not add additional handlers if they are there
    if not len(fileLogger.handlers):
    
        #adding producer handler
        #bHandler= EMQproducer.BroadcastLogHandler(elementName,producer)
        #fileLogger.addHandler(bHandler)
        #EMQproducer.StreamAndBroadcastHandler("TEST",producer)
        
        if filename == None:
            #setting log rotation for 10 files each up to 10000000 bytes (10MB)
            fileHandler = handlers.RotatingFileHandler(HOMEPATH+"/logs/COCOMAlogfile.csv",'a', 10000000, 10)
            fileLoggerFormatter=logging.Formatter ('%(asctime)s;%(name)s;%(levelname)s;%(message)s',datefmt='%m/%d/%Y %H:%M:%S')
            fileHandler.setFormatter(fileLoggerFormatter)
            fileLogger.addHandler(fileHandler)
            
            
            #cli writing handler
            cliLoggerFormatter=logging.Formatter ('%(asctime)s - [%(name)s] - %(levelname)s : %(message)s',datefmt='%m/%d/%Y %H:%M:%S')
            cliHandler = logging.StreamHandler()
            cliHandler.setFormatter(cliLoggerFormatter)
            fileLogger.addHandler(cliHandler)
        
        else:
            fileHandler= logging.FileHandler(HOMEPATH+"/logs/"+str(filename))
            
            fileLoggerFormatter=logging.Formatter ('%(asctime)s;%(name)s;%(levelname)s;%(message)s',datefmt='%m/%d/%Y %H:%M:%S')
            fileHandler.setFormatter(fileLoggerFormatter)
            fileLogger.addHandler(fileHandler)
    
    
    return fileLogger 
开发者ID:cragusa,项目名称:cocoma,代码行数:60,代码来源:Logger.py

示例3: Producer

# 需要导入模块: import Library [as 别名]
# 或者: from Library import getHomepath [as 别名]
from Distribution import distribution
from Logger import singleLogger

import Pyro4
Pyro4.config.HMAC_KEY='pRivAt3Key'
#Pyro4.config.SERIALIZER='pickle'
#perhaps needs to be set somewhere else

distLoggerDM=None

global producer
producer = Producer()
# EMQproducer.StreamAndBroadcastHandler("Distribution Manager",producer,logging.INFO)

global HOMEPATH
HOMEPATH = Library.getHomepath()
   

def createDistribution(newEmulation):
    daemon=Library.getDaemon()
    
    global producer
    if producer is None:
        # print "In distributionManager, copying producer"
        producer = producer()

    # print "Who calls "+sys._getframe(0).f_code.co_name+": "+sys._getframe(1).f_code.co_name
#    distLoggerDM = ""
    
    # if distLoggerDM is None:
    #        distLoggerDM=Library.loggerSet("Distribution Manager",str(newEmulation.emulationID)+"-"+str(newEmulation.emulationName)+"-syslog"+"_"+str(newEmulation.startTimeEmu)+".csv")
开发者ID:cragusa,项目名称:cocoma,代码行数:33,代码来源:DistributionManager.py


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