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


Python Resource.Resource类代码示例

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


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

示例1: __init__

    def __init__(self, name):
        Resource.__init__(self, name)

        self._registry = {}
        self._resources = {}

        return
开发者ID:Netflix,项目名称:vmaf,代码行数:7,代码来源:ResourceManager.py

示例2: __init__

 def __init__(self,max_cores=1,name='Cores'):
     
     Resource.__init__(self)
     
     cores = self.manager.BoundedSemaphore(max_cores)
     
     in_service = InService(     \
         inbox = self.checkinbox ,
         cores = cores           ,
         name  = name+'_checkin' ,
     )        
     
     out_service = OutService(    \
         inbox = self.checkoutbox ,
         cores = cores            ,
         name  = name+'_checkout' ,
     )        
     
     self.name = name
     self.max_cores   = max_cores
     self.cores       = cores
     self.in_service  = in_service
     self.out_service = out_service
     
     self.start()
开发者ID:Aircraft-Design-UniNa,项目名称:SUAVE,代码行数:25,代码来源:ComputeCores.py

示例3: __init__

    def __init__(self, parentObject=None, resourceDescriptor = {}):
        Resource.__init__(self)
        # The resources dictionary is for subclasses of RESTfulResource, routable as http endpoints
        # The Properties dictionary is for serializable objects and strings, get/put but not routable
        self.Resources = RESTfulDictEndpoint(self.resources) #make resources endpoint from the dictionary
        # make properties resource and it's endpoint
        self._properties = {}
        self.Properties = RESTfulDictEndpoint(self._properties) #make Properties endpoint from its dict
        # make an entry in resources to point to properties
        self.Resources.update({'Properties': self.Properties}) # put Properties into the resource dict
        self.Resources.update({'thisObject': self}) #self-identity
        # initialize Properties by putting in the constructor properties
        
        self._resourceDescriptor = resourceDescriptor # for settings and properties update

        if parentObject == None : #no parent means this is a base object, fill in base settings
            self.Resources.update({'baseObject': self})
            self.Resources.update({'parentObject': self})
            self.Properties.update({'pathFromBase': ''})
            self.Properties.update({'resourceName': 'baseObject'})
            self.Properties.update({'resourceClass': 'SmartObject'})
        else : # fill in properties and identity of parent, base, and path to base
            self.Properties.update({'resourceName': resourceDescriptor['resourceName']}) 
            self.Properties.update({'resourceClass': resourceDescriptor['resourceClass']})
            self.Resources.update({'parentObject' : parentObject.Resources.get('thisObject')})
            self.Resources.update({'baseObject': parentObject.Resources.get('baseObject') })
            self.Properties.update({'pathFromBase': self.Resources.get('parentObject').Properties.get('pathFromBase') \
                                   + '/' + self.Properties.get('resourceName')})
            
        self._parseContentTypes = ['*/*'] 
        self._serializeContentTypes = ['*/*']
        self.defaultResources = None
        
        self.resources.update({'l': ResourceList(self)})
开发者ID:EmuxEvans,项目名称:SmartObject,代码行数:34,代码来源:RESTfulResource.py

示例4: resourceSearchTests

def resourceSearchTests(pf):
    try:
       # try out isChild with a non-child resource
       p = Resource("eddie","atype")
       c = Resource("franks|schild","atype|btype")
       theVerdict = p.isChild(c)
    except PTexception, a:
        pf.failed(a.value)
开发者ID:heathharrelson,项目名称:PerfTrack,代码行数:8,代码来源:ptdfClassesTester.py

示例5: get_initial_run_info

def get_initial_run_info(resIdx, attrs, eInfo, ptds):
    """Parses the run data file and addes the information to the Execution
       object, exe."""

    runMachineArg = eInfo.machineName
    # expect only one execution resource in resIdx
    [exe] = resIdx.findResourcesByType("execution")
    (runMachine, runOS, exe, numberOfProcesses, threadsPerProcess) = getInitialAVs(
        resIdx, attrs, exe, runMachineArg, ptds
    )

    envNewName = ptds.getNewResourceName("env")
    env = Resource(envNewName, "environment")
    resIdx.addResource(env)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (exe) = getSubmission(resIdx, attrs, exe, ptds)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (exe) = getFilesystems(resIdx, attrs, exe, ptds)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (env) = getLibraries(resIdx, attrs, env, exe)
        # env.dump(recurse=True)
    if attrs.getCurrent()[0] != "RunDataEnd":
        (exe) = getInputDecks(resIdx, attrs, exe, ptds)

    # expect only one build resource in resIdx
    [build] = resIdx.findResourcesByType("build")

    # check to see if we figured out how many processes there were
    if numberOfProcesses != -1:
        # yes, so create resource entries for all processes and threads
        i = 0
        while i < int(numberOfProcesses):
            process = Resource(
                exe.name + Resource.resDelim + "Process-" + str(i), "execution" + Resource.resDelim + "process"
            )
            resIdx.addResource(process)
            process.addAttribute("environment", env.name, "resource")
            process.addAttribute("build", build.name, "resource")
            process.addAttribute("OS name", runOS.name, "resource")
            if runMachine:
                process.addAttribute("machine name", runMachine.name, "resource")
            j = 0
            while j < int(threadsPerProcess):
                thread = Resource(
                    process.name + Resource.resDelim + "Thread-" + str(j),
                    "execution" + Resource.resDelim + "process" + Resource.resDelim + "thread",
                )
                resIdx.addResource(thread)
                j += 1
            i += 1
    # couldn't figure out number of processes, so link up resources with
    # the execution resource
    else:
        exe.addAttribute("environment", env.name, "resource")
        exe.addAttribute("build", build.name, "resource")
        exe.addAttribute("OS name", runOS.name, "resource")
        if runMachine:
            exe.addAttribute("machine name", runMachine.name, "resource")
开发者ID:heathharrelson,项目名称:PerfTrack,代码行数:58,代码来源:Run.py

示例6: __init__

 def __init__(self, appName="", AVs=None, executions=None):
    Resource.__init__(self,appName,"application")
    if AVs == None:
       self.attributes = []
    else:
       self.attributes = []
       self.addAttributes(AVs)
    if executions == None:
       self.executions = []
    else:
       self.executions = []
       self.addExecutions(executions)
开发者ID:heathharrelson,项目名称:PerfTrack,代码行数:12,代码来源:Application.py

示例7: dump

   def dump(self, indent=0, recurse=False):
       """Dump routine for debugging."""
       i = indent
       ind_str = ""
       while i > 0:
          ind_str += "  "
          i -= 1

       Resource.dump(self, indent, recurse)
       print ind_str + self.name + "'s performanceResults: " \
             + str(len(self.performanceResults)) 
       for p in self.performanceResults:
          p.dump(indent+1, recurse)
开发者ID:heathharrelson,项目名称:PerfTrack,代码行数:13,代码来源:Execution.py

示例8: testAsynchLoad

    def testAsynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.r.load(self, "result", lambda: loader())

        while not self.result:
            self.e.run()

        assert self.result == 0xdada
开发者ID:Richardgriff,项目名称:fofix,代码行数:10,代码来源:ResourceTest.py

示例9: testAsynchLoadSeries

    def testAsynchLoadSeries(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        for i in range(10):
            self.r.load(self, "result%d" % i, loader)

        while not self.result9:
            self.e.run()

        assert self.result9 == 0xdada
开发者ID:Richardgriff,项目名称:fofix,代码行数:11,代码来源:ResourceTest.py

示例10: ResourceTest

class ResourceTest(unittest.TestCase):
    def testAsynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.r.load(self, "result", lambda: loader())

        while not self.result:
            self.e.run()

        assert self.result == 0xdada

    def testSynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        assert self.r.load(self, "result2", loader, synch = True) == 0xdada
        assert self.result2 == 0xdada

    def testAsynchLoadSeries(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        for i in range(10):
            self.r.load(self, "result%d" % i, loader)

        while not self.result9:
            self.e.run()

        assert self.result9 == 0xdada

    def testCallback(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.quux = None
        def loaded(r):
            self.quux = r

        self.r.load(self, "fuuba", loader, onLoad = loaded).join()

        while not self.fuuba:
            self.e.run()

        assert self.fuuba == self.quux

    def setUp(self):
        Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
        # Resource expects game_priority to be an integer,
        # Config won't know unless we define it as such.
        Config.define("performance", "game_priority", int, 2)
        self.e = GameEngine()

    def tearDown(self):
        self.e.quit()
开发者ID:Richardgriff,项目名称:fofix,代码行数:55,代码来源:ResourceTest.py

示例11: testCallback

    def testCallback(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.quux = None
        def loaded(r):
            self.quux = r

        self.r.load(self, "fuuba", loader, onLoad = loaded).join()

        while not self.fuuba:
            self.e.run()

        assert self.fuuba == self.quux
开发者ID:Richardgriff,项目名称:fofix,代码行数:14,代码来源:ResourceTest.py

示例12: ResourceTest

class ResourceTest(unittest.TestCase):
    def testAsynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.r.load(self, "result", lambda: loader())

        while not self.result:
            self.e.run()

        assert self.result == 0xdada

    def testSynchLoad(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        assert self.r.load(self, "result2", loader, synch = True) == 0xdada
        assert self.result2 == 0xdada

    def testAsynchLoadSeries(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        for i in range(10):
            self.r.load(self, "result%d" % i, loader)

        while not self.result9:
            self.e.run()

        assert self.result9 == 0xdada

    def testCallback(self):
        self.r = Resource()
        self.e.addTask(self.r, synchronized = False)

        self.quux = None
        def loaded(r):
            self.quux = r

        self.r.load(self, "fuuba", loader, onLoad = loaded).join()

        while not self.fuuba:
            self.e.run()

        assert self.fuuba == self.quux

    def setUp(self):
        self.e = Engine()

    def tearDown(self):
        self.e.quit()
开发者ID:Hawkheart,项目名称:fof-reborn,代码行数:51,代码来源:ResourceTest.py

示例13: __str__

    def __str__(self):
        symbolstr = ", ".join(["%s" %  k for k in sorted(self.getSymbolCardLists().keys())])
        secondCollection = ["%s" % k for k, l in sorted(self.getSymbolCardLists().items()) if len(l) > 1]
        if secondCollection:
            symbolstr += " || " + ", ".join(secondCollection)  
        multistrs = []
        for symbol, cards in self.getMultiplierCardsBySymbol():
            factor = sum([c.getMultiplier() for c in cards])
            multistrs.append("%d x %s" % (factor, symbol.name))
        return """%s%s%s
People: %d, Foodtrack: %d, Food: %d, Tools: %s, One-time tools: %s
Resources: %s
Hutcount: %d
Symbolcards: %s (%d)
Multipliercards: %s (%d)   
score (cardscore): %d (%d)\n""" % (self.colorOS, self.color.name, self.colorOSnormal, \
                  self.getPersonCount(), self.getFoodTrack(), self.resources.count(Resource.food), self.toolbox, self.oneTimeTools,  
                  Resource.coloredOutput(sorted(self.getNonFood())), 
                  len(self.huts), \
                  symbolstr, self.symbolCardPoints(), \
                  ", ".join(multistrs), self.multiplierCardPoints(),\
                  self.getScore(), self.getCardScore())
开发者ID:dennisdjensen,项目名称:python-proj,代码行数:22,代码来源:Player.py

示例14: wantsToBuy

 def wantsToBuy(self, outstring, nonFoodResources, hutOrCard):
     return fetchConvertedInput("with available resources: %s\ndo you want to buy this %s (y|n): %s ? (y) " % (Resource.coloredOutput(nonFoodResources),outstring, str(hutOrCard)),
                                lambda v: printfString("please answer y(es) or n(o) - not: '%s'", v),
                                yesNo,
                                self.printPlayersFunc) 
开发者ID:dennisdjensen,项目名称:python-proj,代码行数:5,代码来源:Strategy.py

示例15: doBuyCards

 def doBuyCards(self, player, cards, boughtCards, players, cardPile):
     for card in cards:
         if len(player.getNonFood()) < card[1]: 
             print("with available resources: %s you can't afford the following card:\nprice %d%s\n " % (Resource.coloredOutput(player.getNonFood()), card[1], str(card[0])))
         elif self.wantsToBuy("card", player.getNonFood(), card[0]):
             player.buyCard(card[0], players, cardPile, player.getNonFood()[:card[1]])
             boughtCards.append(card[0])
     return boughtCards 
开发者ID:dennisdjensen,项目名称:python-proj,代码行数:8,代码来源:Strategy.py


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