本文整理汇总了Python中FileDict.FileDict.setValue方法的典型用法代码示例。如果您正苦于以下问题:Python FileDict.setValue方法的具体用法?Python FileDict.setValue怎么用?Python FileDict.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileDict.FileDict
的用法示例。
在下文中一共展示了FileDict.setValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromDir
# 需要导入模块: from FileDict import FileDict [as 别名]
# 或者: from FileDict.FileDict import setValue [as 别名]
#.........这里部分代码省略.........
self.javaOpt = FileDict(os.path.join(self.home, 'java.settings'), exists=not newjob) # start with "-D"
self.metaOpt = FileDict(os.path.join(self.home, 'meta.settings'), exists=not newjob) # xmx, jar, profile, etc
self.qsubOpt = FileDict(os.path.join(self.home, 'qsub.settings'), exists=not newjob) # mem_free, h_rt
self.prepared = False
def getResourceDirectory(self, parentFolderName, childFolderName, overwrite=True):
'''see getResourceFile for details'''
folder = os.path.join(self.home, parentFolderName, childFolderName)
if os.path.isdir(folder):
if not overwrite: raise
else:
os.system('mkdir -p ' + folder)
return folder
def getResourceFile(self, folderName, fileName, overwrite=True):
'''
example usage: folderName='diagnostics', fileName='parameters.txt',
this just returns a path to home/diagnostics/parameters.txt
resources are usefule for job-specific output (avoid job output collision)
'''
folder = os.path.join(self.home, folderName)
if not os.path.isdir(folder):
os.system('mkdir ' + folder)
f = os.path.join(folder, fileName)
if not overwrite and os.path.isfile(f):
raise Exception('this file already exists! ' + f)
return f
def addLib(self, dirOrFile):
if os.path.isfile(dirOrFile):
cp = selt.class_path() + ':' + dirOrFile
self.metaOpt.setValue('class_path', cp)
else:
l = all_jars_in(dirOrFile)
l.append(self.class_path())
self.metaOpt.setValue('class_path', ':'.join(l))
def jar(self):
return self.metaOpt.getValue('jar')
def main_class(self):
return self.metaOpt.getValue('main_class')
def class_path(self):
return self.metaOpt.getValue('class_path')
def xmx(self):
return self.metaOpt.getValue('xmx')
def profile(self):
return self.metaOpt.getValue('profile', 'n') == 'y'
def mem_free(self):
return self.qsubOpt.getValue('mem_free')
def use_asserts(self):
return str2bool(self.metaOpt.getValue('asserts'))
def command_line_args(self):
f = codecs.open(os.path.join(self.home, 'command_line_args.txt'), 'r', 'utf-8')
args = [x.strip() for x in f.readlines()]
f.close()
return args