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


Python ComponentProxy.set_reservations方法代码示例

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


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

示例1: float

# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_reservations [as 别名]
        if spec['cycle']:
            start = spec['start']
            duration = spec['duration']
            cycle = float(spec['cycle'])
            now = time.time()
            periods = math.floor((now - start)/cycle)
    
            if(periods < 0):
                start += cycle
            elif(now - start) % cycle < duration:
                start += (periods + 1) * cycle
            else:
                start += (periods + 2) * cycle

            updates = {'start':start}
            try:
                scheduler.set_reservations([{'name':spec['name']}], updates, user_name)
            except:
                print "Error deferring reservation '%'" % spec['name']
                continue
            
            newstart = time.strftime("%c", time.localtime(start))
            print "Setting new start time for for reservation '%s': %s" % (spec['name'], newstart)
        else:
            try:
                scheduler.del_reservations([{'name':spec['name']}], user_name)
            except:
                print "Error releasing reservation '%s'" % spec['name']
                continue
            
            print "Releasing reservation '%s'" % spec['name']
开发者ID:benmcclelland,项目名称:cobalt-orcm,代码行数:33,代码来源:userres.py

示例2:

# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import set_reservations [as 别名]
        else:
            if start:
                updates['start'] = starttime
            if duration:
                updates['duration'] = dsec
            
        if user:
            updates['users'] = user
        if project_specified:
            updates['project'] = project
        if cycle_time:
            updates['cycle'] = cycle_time
        if partitions:
            updates['partitions'] = ":".join(partitions)
                
        scheduler.set_reservations([{'name':rname}], updates, pwd.getpwuid(os.getuid())[0])
        print scheduler.check_reservations()

        raise SystemExit, 0
    spec = { 'partitions': ":".join(partitions), 'name': nameinfo, 'users': user, 'start': starttime, 'duration': dsec, 'cycle': cycle_time, 'project': project }
    if '-q' in sys.argv:
        spec['queue'] = [opt[1] for opt in opts if opt[0] == '-q'][0]
    try:
        print scheduler.add_reservations([spec], pwd.getpwuid(os.getuid())[0])
        print scheduler.check_reservations()
    except xmlrpclib.Fault, flt:
        if flt.faultCode == ComponentLookupError.fault_code:
            print "Couldn't contact the scheduler"
            sys.exit(1)
        else:
            print flt.faultString
开发者ID:wtangiit,项目名称:Qsim,代码行数:33,代码来源:setres.py


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