本文整理汇总了Python中Ganga.GPIDev.Lib.File.FileUtils.doesFileExist方法的典型用法代码示例。如果您正苦于以下问题:Python FileUtils.doesFileExist方法的具体用法?Python FileUtils.doesFileExist怎么用?Python FileUtils.doesFileExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ganga.GPIDev.Lib.File.FileUtils
的用法示例。
在下文中一共展示了FileUtils.doesFileExist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare
# 需要导入模块: from Ganga.GPIDev.Lib.File import FileUtils [as 别名]
# 或者: from Ganga.GPIDev.Lib.File.FileUtils import doesFileExist [as 别名]
def prepare(self, app, appsubconfig, appmasterconfig, jobmasterconfig):
inputsandbox, outputsandbox = sandbox_prepare(app, appsubconfig, appmasterconfig, jobmasterconfig)
job = app.getJobObject()
if job.inputdata:
if not job.splitter:
if len(job.inputdata) > 100:
raise BackendError(
"You're submitting a job to Dirac with no splitter and more than 100 files, please add a splitter and try again!"
)
outputfiles = [this_file for this_file in job.outputfiles if isType(this_file, DiracFile)]
data_str = "import os\n"
data_str += "execfile('data.py')\n"
if hasattr(job, "_splitter_data"):
data_str += job._splitter_data
inputsandbox.append(FileBuffer("data-wrapper.py", data_str))
input_data = []
# Cant wait to get rid of this when people no-longer specify
# inputdata in options file
#######################################################################
# splitters ensure that subjobs pick up inputdata from job over that in
# optsfiles but need to take care of unsplit jobs
if not job.master:
share_path = os.path.join(get_share_path(app), "inputdata", "options_data.pkl")
if not job.inputdata:
if os.path.exists(share_path):
f = open(share_path, "r+b")
job.inputdata = pickle.load(f)
f.close()
#######################################################################
# Cant wait to get rid of this when people no-longer specify
# outputsandbox or outputdata in options file
#######################################################################
share_path = os.path.join(get_share_path(app), "output", "options_parser.pkl")
if os.path.exists(share_path):
# if not os.path.exists(share_path):
# raise GangaException('could not find the parser')
f = open(share_path, "r+b")
parser = pickle.load(f)
f.close()
outbox, outdata = parser.get_output(job)
from Ganga.GPIDev.Lib.File import FileUtils
from Ganga.GPIDev.Base.Filters import allComponentFilters
fileTransform = allComponentFilters["gangafiles"]
outdata_files = [
fileTransform(this_file, None)
for this_file in outdata
if not FileUtils.doesFileExist(this_file, job.outputfiles)
]
job.non_copyable_outputfiles.extend(
[output_file for output_file in outdata_files if not isType(output_file, DiracFile)]
)
outbox_files = [
fileTransform(this_file, None)
for this_file in outbox
if not FileUtils.doesFileExist(this_file, job.outputfiles)
]
job.non_copyable_outputfiles.extend(
[outbox_file for outbox_file in outbox_files if not isType(outbox_file, DiracFile)]
)
outputsandbox = [f.namePattern for f in job.non_copyable_outputfiles]
outputsandbox.extend([f.namePattern for f in job.outputfiles if not isType(f, DiracFile)])
outputsandbox = unique(outputsandbox) # + outbox[:])
#######################################################################
input_data_dirac, parametricinput_data = dirac_inputdata(job.application)
if input_data_dirac is not None:
for f in input_data_dirac:
if isType(f, DiracFile):
input_data.append(f.lfn)
elif isType(f, str):
input_data.append(f)
else:
raise ApplicationConfigurationError(
"Don't know How to handle anythig other than DiracFiles or strings to LFNs!"
)
commandline = "python ./gaudipython-wrapper.py"
if is_gaudi_child(app):
commandline = "gaudirun.py "
commandline += " ".join([str(arg) for arg in app.args])
commandline += " options.pkl data-wrapper.py"
logger.debug("Command line: %s: ", commandline)
#.........这里部分代码省略.........
示例2: prepare
# 需要导入模块: from Ganga.GPIDev.Lib.File import FileUtils [as 别名]
# 或者: from Ganga.GPIDev.Lib.File.FileUtils import doesFileExist [as 别名]
def prepare(self, app, appsubconfig, appmasterconfig, jobmasterconfig):
logger.debug("Prepare")
inputsandbox, outputsandbox = sandbox_prepare(app, appsubconfig, appmasterconfig, jobmasterconfig)
job = app.getJobObject()
logger.debug("Loading pickle files")
#outputfiles=set([file.namePattern for file in job.outputfiles]).difference(set(getOutputSandboxPatterns(job)))
# Cant wait to get rid of this when people no-longer specify
# inputdata in options file
#######################################################################
# splitters ensure that subjobs pick up inputdata from job over that in
# optsfiles but need to take sare of unsplit jobs
if not job.master:
share_path = os.path.join(get_share_path(app),
'inputdata',
'options_data.pkl')
if not job.inputdata:
if os.path.exists(share_path):
f = open(share_path, 'r+b')
job.inputdata = pickle.load(f)
f.close()
#######################################################################
# Cant wait to get rid of this when people no-longer specify
# outputsandbox or outputdata in options file
#######################################################################
share_path = os.path.join(get_share_path(app),
'output',
'options_parser.pkl')
logger.debug("Adding info from pickle files")
if os.path.exists(share_path):
f = open(share_path, 'r+b')
parser = pickle.load(f)
f.close()
outbox, outdata = parser.get_output(job)
from Ganga.GPIDev.Lib.File import FileUtils
from Ganga.GPIDev.Base.Filters import allComponentFilters
fileTransform = allComponentFilters['gangafiles']
job.non_copyable_outputfiles.extend([fileTransform(this_file, None) for this_file in outdata if not FileUtils.doesFileExist(this_file, job.outputfiles)])
job.non_copyable_outputfiles.extend([fileTransform(this_file, None) for this_file in outbox if not FileUtils.doesFileExist(this_file, job.outputfiles)])
outputsandbox = [f.namePattern for f in job.non_copyable_outputfiles]
outputsandbox.extend([f.namePattern for f in job.outputfiles])
outputsandbox = unique(outputsandbox)
#######################################################################
logger.debug("Doing XML Catalog stuff")
data = job.inputdata
data_str = ''
if data:
logger.debug("Returning options String")
data_str = data.optionsString()
if data.hasLFNs():
logger.debug("Returning Catalogue")
inputsandbox.append(
FileBuffer('catalog.xml', data.getCatalog()))
cat_opts = '\nfrom Gaudi.Configuration import FileCatalog\nFileCatalog().Catalogs = ["xmlcatalog_file:catalog.xml"]\n'
data_str += cat_opts
logger.debug("Doing splitter_data stuff")
if hasattr(job, '_splitter_data'):
data_str += job._splitter_data
inputsandbox.append(FileBuffer('data.py', data_str))
logger.debug("Doing GaudiPython stuff")
cmd = 'python ./gaudipython-wrapper.py'
opts = ''
if is_gaudi_child(job.application):
opts = 'options.pkl'
cmd = 'gaudirun.py ' + \
' '.join(job.application.args) + ' %s data.py' % opts
logger.debug("Setting up script")
script = script_generator(create_runscript(job.application.newStyleApp),
remove_unreplaced=False,
OPTS=opts,
PROJECT_OPTS=job.application.setupProjectOptions,
APP_NAME=job.application.appname,
APP_VERSION=job.application.version,
APP_PACKAGE=job.application.package,
PLATFORM=job.application.platform,
CMDLINE=cmd,
XMLSUMMARYPARSING=getXMLSummaryScript()) # ,
# OUTPUTFILESINJECTEDCODE = getWNCodeForOutputPostprocessing(job, ''))
logger.debug("Returning StandardJobConfig")
#.........这里部分代码省略.........