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


Python Library类代码示例

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


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

示例1: get_language_snippets

        def get_language_snippets(self, path, name = None):
                library = Library()
                
                name = self.get_language(path)
                nodes = library.get_snippets(name)

                return nodes
开发者ID:kaushikmit,项目名称:gedit,代码行数:7,代码来源:Manager.py

示例2: noExtraOptions

def noExtraOptions(options, *arg):
    options = vars(options)
    for argOption in arg:
        Library.removeFromDict(options, argOption)
    for optionValue in options.values():
        if not (optionValue == False):
            print "Bad option combination"
            sys.exit()
开发者ID:cragusa,项目名称:cocoma,代码行数:8,代码来源:ccmsh.py

示例3: singleLogger

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,代码行数:58,代码来源:Logger.py

示例4: unref_languages

        def unref_languages(self):
                piter = self.model.get_iter_first()
                library = Library()
                
                while piter:
                        if self.is_filled(piter):
                                language = self.get_language(self.model.get_path(piter))
                                library.save(language)

                                library.unref(language)
                        
                        piter = self.model.iter_next(piter)
开发者ID:kaushikmit,项目名称:gedit,代码行数:12,代码来源:Manager.py

示例5: __init__

	def __init__(self):
		self.dir = os.getcwd()
		self.library = Library(self.dir)
		#self.musicPlayer = threading.Thread(target=MusicPlayer.__init__, args = [self.library])
		self.musicPlayer = MusicPlayer(self.library)
		self.musicPlayer.start()
		self.commandList = "download (song) - downloads a song to your library \nlist (songs/playlists) [start] - Lists your songs or playlists, optionally starting with certain character(s) \ncreate playlist (name) - creates a playlist with given name \nadd (song) :: (playlist) - adds given song in your library to given playlist \nshuffle [playlist] - shuffles your main library or a specific playlist \nplay (song/playlist) - plays the current music if no argument give, or plays a song or a playlist \ndelete (song/playlist) - removes a song or a playlist \npause - pauses the music \nrewind - rewinds the music \nskip - skips to the next song\ninfo - gives info about Tünz \nexit - exits Tünz"
开发者ID:importUsername,项目名称:Tunz,代码行数:7,代码来源:Tünz2.py

示例6: process_ATOM

    def process_ATOM(self, rec):
        ## load current atom since this record indicates a new atom
        if self.atm_map:
            self.load_atom(self.atm_map)
            self.atm_map = {}

        ## optimization
        atm_map = self.atm_map

        ## always derive element from atom name for PDB files -- they are
        ## too messed up to use the element column
        try:
            name = rec["name"]
        except KeyError:
            atm_map["name"] = ""
            atm_map["element"] = ""
        else:
            atm_map["name"] = name.strip()
            
            res_name = rec.get("resName", "")
            gelement = Library.library_guess_element_from_name(name, res_name)
            if gelement != None:
                atm_map["element"] = gelement

        ## additional atom information
        if rec.has_key("serial"):
            atm_map["serial"] = rec["serial"]

        if rec.has_key("altLoc"):
            atm_map["alt_loc"] = rec["altLoc"]

        if rec.has_key("resName"):
            atm_map["res_name"] = rec["resName"]

        if rec.has_key("chainID"):
            atm_map["chain_id"] = rec["chainID"]

        ## construct fragment_id
        if rec.has_key("resSeq"):
            if rec.has_key("iCode"):
                atm_map["fragment_id"] = "%d%s" % (rec["resSeq"],rec["iCode"])
            else:
                atm_map["fragment_id"] = "%d" % (rec["resSeq"])
                
        ## add the model number for the atom
        if self.model_num != None:
            atm_map["model_id"] = self.model_num

        ## position
        if rec.has_key("x"):
            atm_map["x"] = rec["x"]
        if rec.has_key("y"):
            atm_map["y"] = rec["y"]
        if rec.has_key("z"):
            atm_map["z"] = rec["z"]

        if rec.has_key("occupancy"):
            atm_map["occupancy"] = rec["occupancy"]
        if rec.has_key("tempFactor"):
            atm_map["temp_factor"] = rec["tempFactor"]
开发者ID:davem22101,项目名称:semanticscience,代码行数:60,代码来源:PDBBuilder.py

示例7: loadMon

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,代码行数:33,代码来源:Logger.py

示例8: setDistrType

 def setDistrType(self, distrType):
     distroList = Library.listDistributions("all")
     for distName in distroList:
         if distrType.lower() == distName.lower():
             return distrType
     
     raise Exception("Distribution module '%s' does not exist. Check the name" % (distrType))
开发者ID:cragusa,项目名称:cocoma,代码行数:7,代码来源:Distribution.py

示例9: show_all_results

def show_all_results():
    '''
    Show summary of emulations results
    '''
    #curl -k -i http://10.55.164.232:8050/distributions/linear
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD') 
    emuList=Library.getEmulationList("all")
    
    #root element
    resultsCollection = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/results'})
    items =ET.SubElement(resultsCollection,'items', { 'offset':'0','total':str(len(emuList))})
        
        
    for elem in emuList :
        failedRunsInfo=elem["failedRunsInfo"]
        
        
        #print "---->\nID: "+str(elem["ID"])+"\nName: "+str(elem["Name"])+"\nState: "+str(elem["State"])+"\nTotal Runs: "+str(elem["runsTotal"])+"\nExecuted Runs: "+str(elem["runsExecuted"])+"\nFailed Runs: "+str(len(failedRunsInfo))
        
        emuResults = ET.SubElement(items,'results', { 'href':'/results/'+str(elem["Name"]),'failedRuns':str(len(failedRunsInfo)),'name':str(elem["Name"]),'state':str(elem["State"])})


        
    
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(resultsCollection, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    
    

    return prettify(resultsCollection)   
开发者ID:cragusa,项目名称:cocoma,代码行数:34,代码来源:ccmshAPI.py

示例10: get_tests

def get_tests():
    '''
    List all available tests in the "/tests" folder
    '''
    
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD, POST')     
    
    testsList=Library.listTests("all")
    #print "testsList",testsList
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document.
    '''

    #building the XML we will return
    tests = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/tests'})
    #<items offset="0" total="2">
    items =ET.SubElement(tests,'items', { 'offset':'0','total':str(len(testsList))})
    
    #<distribution href="/emulations/1" name="Emu1"/>
    
    for elem in testsList :
        test = ET.SubElement(items,'test', { 'href':'/tests/'+str(elem),'name':str(elem)})
        
        
    
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(tests, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    
    
    

    return prettify(tests)
开发者ID:cragusa,项目名称:cocoma,代码行数:35,代码来源:ccmshAPI.py

示例11: get_emulators

def get_emulators():
    '''
    Display list of emulators
    '''
    ET.register_namespace("test", "http://127.0.0.1/cocoma")
    response.set_header('Content-Type', 'application/vnd.bonfire+xml')
    response.set_header('Accept', '*/*')
    response.set_header('Allow', 'GET, HEAD')     
    
    emuList=Library.listEmulators("all")
    #print "emulist",emuList
    '''
    XML namespaces are used for providing uniquely named elements and attributes in an XML document.
    '''
     
    #building the XML we will return
    emulators = ET.Element('collection', { 'xmlns':'http://127.0.0.1/cocoma','href':'/emulators'})
    #<items offset="0" total="2">
    items =ET.SubElement(emulators,'items', { 'offset':'0','total':str(len(emuList))})
    
    #<emulator href="/emulations/1" name="Emu1"/>
    
    for elem in emuList :
        emulator = ET.SubElement(items,'emulator', { 'href':'/emulators/'+str(elem),'name':str(elem)})
        
    #<link href="/" rel="parent" type="application/vnd.cocoma+xml"/>
    lk = ET.SubElement(emulators, 'link', {'rel':'parent', 'href':'/', 'type':'application/vnd.bonfire+xml'})
    
  
    return prettify(emulators)
开发者ID:cragusa,项目名称:cocoma,代码行数:30,代码来源:ccmshAPI.py

示例12: rec

def rec(N,tot,number,isG=False):
    sums=0
    for i in xrange(0,10):
        num = number*10+i
        if isG and Library.miller_rabin(num,10):
            sums+=num
        if num % (tot+i)!=0:continue
        div = num/(tot+i)     
        if N < lim-1:
            if N !=1:
                if Library.miller_rabin(div,10):
                    sums+=rec(N+1,tot+i,num,True)
                else:
                    sums+=rec(N+1,tot+i,num)
            else:
                sums+=rec(N+1,tot+i,num) 
    return sums 
开发者ID:DanielGabric,项目名称:ProjectEuler,代码行数:17,代码来源:ProjectEuler387.py

示例13: startAPI

def startAPI(IP_ADDR,PORT_ADDR):

    if Library.daemonCheck() ==0:
            print "\n---Check if Scheduler Daemon is started. Connection error---"
            sys.exit(0)
  
    print"API IP address:",IP_ADDR

    API_HOST=run(host=IP_ADDR, port=PORT_ADDR)
    return IP_ADDR
开发者ID:cragusa,项目名称:cocoma,代码行数:10,代码来源:ccmshAPI.py

示例14: one_letter_code

 def one_letter_code(self):
     """Return the one letter code representation of the sequence as a string.
     """
     seqlist = list()
     for threeletter in self.sequence_list:
         mdesc = Library.library_get_monomer_desc(threeletter)
         if mdesc is not None and mdesc.one_letter_code:
             seqlist.append(mdesc.one_letter_code)
         else:
             seqlist.append("X")
     return "".join(seqlist)
开发者ID:davem22101,项目名称:semanticscience,代码行数:11,代码来源:Sequence.py

示例15: main

def main():
    library = Library()
    library.read_book_collection()
    print len(library.collection), 'books in collection.'
    print "Ready for input. Type 'help()' for a list of commands.\n"
    command = '\0'
    while command != 'quit()':
        try:
            command = raw_input('Library command: ').strip()
            if len(command) == 0:
                print "What? Speak up!\n"
            else:
                eval('library.' + command)
                print library.response
                library.response = ''
        except AttributeError, e:
            print "Sorry, I didn't understand:", command
            print "Type 'help()' for a list of the things I do understand.\n"
        except Exception, e:
            print "Unexpected error:", e            
开发者ID:RyCSmith,项目名称:Library,代码行数:20,代码来源:RunLibrary.py


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