本文整理汇总了Python中Cobalt.Proxy.ComponentProxy.del_reservations方法的典型用法代码示例。如果您正苦于以下问题:Python ComponentProxy.del_reservations方法的具体用法?Python ComponentProxy.del_reservations怎么用?Python ComponentProxy.del_reservations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cobalt.Proxy.ComponentProxy
的用法示例。
在下文中一共展示了ComponentProxy.del_reservations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: float
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import del_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']
示例2: ComponentProxy
# 需要导入模块: from Cobalt.Proxy import ComponentProxy [as 别名]
# 或者: from Cobalt.Proxy.ComponentProxy import del_reservations [as 别名]
scheduler = ComponentProxy("scheduler", defer=False)
except ComponentLookupError:
print "Failed to connect to scheduler"
raise SystemExit, 1
# Check if reservation exists
spec = [{'name': arg} for arg in args]
try:
result = scheduler.get_reservations(spec)
except xmlrpclib.Fault, flt:
if flt.faultCode == 1:
print "Error communicating with queue manager"
sys.exit(1)
if len(result) and len(result) != len(args):
print "Reservation subset matched"
elif not result:
print "No Reservations matched"
raise SystemExit, 1
try:
result = scheduler.del_reservations(spec, pwd.getpwuid(os.getuid())[0])
except xmlrpclib.Fault, flt:
if flt.faultCode == 1:
print "Error communicating with queue manager"
sys.exit(1)
print "Released reservation '%s', matched on %d partitions" % \
(','.join(args), len(result))