本文整理汇总了Python中Factory.Factory.printDump方法的典型用法代码示例。如果您正苦于以下问题:Python Factory.printDump方法的具体用法?Python Factory.printDump怎么用?Python Factory.printDump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory.Factory
的用法示例。
在下文中一共展示了Factory.printDump方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Factory import Factory [as 别名]
# 或者: from Factory.Factory import printDump [as 别名]
class ClusterLauncher:
def __init__(self):
self.factory = Factory()
def parseJobsFile(self, template_dir, job_file):
jobs = []
# We expect the job list to be named "job_list"
filename = template_dir + job_file
try:
data = ParseGetPot.readInputFile(filename)
except: # ParseGetPot class
print "Parse Error: " + filename
return jobs
# We expect our root node to be called "Jobs"
if 'Jobs' in data.children:
jobs_node = data.children['Jobs']
# Get the active line
active_jobs = None
if 'active' in jobs_node.params:
active_jobs = jobs_node.params['active'].split(' ')
for jobname, job_node in jobs_node.children.iteritems():
# Make sure this job is active
if active_jobs != None and not jobname in active_jobs:
continue
# First retrieve the type so we can get the valid params
if 'type' not in job_node.params:
print "Type missing in " + filename
sys.exit(1)
params = self.factory.getValidParams(job_node.params['type'])
params['job_name'] = jobname
# Now update all the base level keys
params_parsed = set()
params_ignored = set()
for key, value in job_node.params.iteritems():
params_parsed.add(key)
if key in params:
if params.type(key) == list:
params[key] = value.split(' ')
else:
if re.match('".*"', value): # Strip quotes
params[key] = value[1:-1]
else:
params[key] = value
else:
params_ignored.add(key)
# Make sure that all required parameters are supplied
required_params_missing = params.required_keys() - params_parsed
if len(required_params_missing):
print 'Required Missing Parameter(s): ', required_params_missing
sys.exit(1)
if len(params_ignored):
print 'Ignored Parameter(s): ', params_ignored
jobs.append(params)
return jobs
def createAndLaunchJob(self, template_dir, job_file, specs, options):
next_dir = getNextDirName(specs['job_name'], os.listdir('.'))
os.mkdir(template_dir + next_dir)
# Log it
if options.message:
f = open(template_dir + 'jobs.log', 'a')
f.write(next_dir.ljust(20) + ': ' + options.message + '\n')
f.close()
saved_cwd = os.getcwd()
os.chdir(template_dir + next_dir)
# Turn the remaining work over to the Job instance
# To keep everything consistent we'll also append our serial number to our job name
specs['job_name'] = next_dir
job_instance = self.factory.create(specs['type'], specs)
# Copy files
job_instance.copyFiles(job_file)
# Prepare the Job Script
job_instance.prepareJobScript()
# Launch it!
job_instance.launch()
os.chdir(saved_cwd)
def registerJobType(self, type, name):
self.factory.register(type, name)
### Parameter Dump ###
def printDump(self):
self.factory.printDump("Jobs")
#.........这里部分代码省略.........