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


Python FileDict.flush方法代码示例

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


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

示例1: fromDir

# 需要导入模块: from FileDict import FileDict [as 别名]
# 或者: from FileDict.FileDict import flush [as 别名]

#.........这里部分代码省略.........
		self.prepared = True
	
	def setSubmission(self, class_path, main_class, args, jar=None, xmx='2G', mem_free='3G', \
			profile=False, asserts=True, actuallySubmit=False):

		f = codecs.open(os.path.join(self.home, 'command_line_args.txt'), 'w', 'utf-8')
		for a in args:
			f.write(a + '\n')
		f.close()

		xmx = canonicalMemoryDescription(xmx)
		mem_free = canonicalMemoryDescription(mem_free)

		if jar is None: jar = 'None'
		self.metaOpt.setValue('jar', jar)
		self.metaOpt.setValue('main_class', main_class)
		self.metaOpt.setValue('class_path', class_path)
		self.metaOpt.setValue('xmx', xmx)
		self.qsubOpt.setValue('mem_free', mem_free)
		self.metaOpt.setValue('profile', bool2str(profile))
		self.metaOpt.setValue('asserts', bool2str(asserts))

		self.prepare()
		if actuallySubmit:
			self.submit()
	
	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
		'''
开发者ID:twolfe18,项目名称:twpt,代码行数:70,代码来源:tsub.py


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