本文整理汇总了Python中FileDict.FileDict.hasKey方法的典型用法代码示例。如果您正苦于以下问题:Python FileDict.hasKey方法的具体用法?Python FileDict.hasKey怎么用?Python FileDict.hasKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileDict.FileDict
的用法示例。
在下文中一共展示了FileDict.hasKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromDir
# 需要导入模块: from FileDict import FileDict [as 别名]
# 或者: from FileDict.FileDict import hasKey [as 别名]
#.........这里部分代码省略.........
def submit(self):
# don't submit the same job twice
assert self.submittedAt() is None
assert self.jid() is None
assert self.prepared
qsubScript = self.qsubScript()
self.metaOpt.setValue('submitted', timestamp())
self.metaOpt.flush()
self.javaOpt.flush()
self.qsubOpt.flush()
r = subprocess.check_output("qsub -N %s %s" % (self.name, qsubScript), shell=True)
jid = int(r.split()[2])
self.metaOpt.setValue('jid', jid, flush=True)
print "submitted job \"%s\" (%d)" % (self.name, jid)
def submittedAt(self):
s = self.metaOpt.getValue('submitted')
if s: return parsetime(s)
else: return None
def jid(self):
s = self.metaOpt.getValue('jid')
if s: return int(s)
else: return None
def failed(self):
if self.recentlySubmitted():
return False
f = self.newestLog()
if not f:
print 'there is no log file, assuming it failed!'
else:
return self.f_hasFailed(f)
def recentlySubmitted(self):
'''
give qsub some time to get its stuff together...
for the first 5 seconds after submitting, just assume the
job is running normally
'''
assert self.submittedAt() is not None
return time.time() - self.submittedAt() < 10.0
def isFinished(self):
if self.recentlySubmitted() or self.isRunning():
return False
self.metaOpt.load()
return self.metaOpt.hasKey('finished')
def isRunning(self):
if self.recentlySubmitted():
return True
assert self.jid() is not None
assert type(self.jid()) is int
running = Job.jobsRunning()
return self.jid() in running
def wait(self, timeout=48*60*60, secsBetweenPolls=30, exceptionOnTimeout=False):
assert self.jid() is not None
assert type(self.jid()) is int
total = 0
while total < timeout and self.isRunning():
total += secsBetweenPolls
time.sleep(secsBetweenPolls)
if exceptionOnTimeout and total >= timeout:
raise Exception("waited for %d seconds and job is not done!" % (total))
else:
print "waited %d seconds, but %d is done!" % (total, self.jid())
def kill(self):
if not self.isRunning():
raise Exception('jid is none, job is not live')
assert self.jid() is not None
assert type(self.jid()) is int
os.system("qdel %d" % (self.jid()))
def pause(self):
if not self.isRunning():
raise Exception('jid is none, job is not live')
assert self.jid() is not None
assert type(self.jid()) is int
os.system("qalter -u %d" % (self.jid()))
def unpause(self):
if not self.isRunning():
raise Exception('jid is none, job is not live')
assert self.jid() is not None
assert type(self.jid()) is int
os.system("qalter -U %d" % (self.jid()))
def logs(self):
assert self.logDir is not None and os.path.isdir(self.logDir)
return [os.path.join(self.logDir, x) for x in os.listdir(self.logDir)]
def newestLog(self):
l = self.logs()
if len(l) == 0:
raise Exception('there are no logs!')
return l[-1]