本文整理汇总了Python中CRABClient.Commands.SubCommand.SubCommand.validateOptions方法的典型用法代码示例。如果您正苦于以下问题:Python SubCommand.validateOptions方法的具体用法?Python SubCommand.validateOptions怎么用?Python SubCommand.validateOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRABClient.Commands.SubCommand.SubCommand
的用法示例。
在下文中一共展示了SubCommand.validateOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
After doing the general options validation from the parent SubCommand class,
do the validation of options that are specific to the submit command.
"""
## First call validateOptions() from the SubCommand class.
SubCommand.validateOptions(self)
## If no configuration file was passed as an option, try to extract it from the arguments.
## Assume that the arguments can only be:
## 1) the configuration file name, and
## 2) parameters to override in the configuration file.
## The last ones should all contain an '=' sign, so these are not candidates to be the
## configuration file argument. Also, the configuration file name should end with '.py'.
## If can not find a configuration file candidate, use the default 'crabConfig.py'.
## If find more than one candidate, raise ConfigurationException.
if self.options.config is None:
use_default = True
if len(self.args):
config_candidates = [(arg,i) for i,arg in enumerate(self.args) if '=' not in arg and arg[-3:] == '.py']
config_candidate_names = set([config_candidate_name for (config_candidate_name,_) in config_candidates])
if len(config_candidate_names) == 1:
self.options.config = config_candidates[0][0]
del self.args[config_candidates[0][1]]
use_default = False
elif len(config_candidate_names) > 1:
self.logger.info('Unable to unambiguously extract the configuration file from the command-line arguments.')
self.logger.info('Possible candidates are: %s' % list(config_candidate_names))
raise ConfigurationException('ERROR: Unable to extract configuration file from command-line arguments.')
if use_default:
self.options.config = 'crabConfig.py'
示例2: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
if self.options.sitename is None:
msg = "%sError%s: Please specify the site where to check the write permissions." % (colors.RED, colors.NORMAL)
msg += " Use the --site option."
ex = MissingOptionException(msg)
ex.missingOption = "sitename"
raise ex
if hasattr(self.options, 'command') and self.options.command != None:
AvailableCommands = ['LCG', 'GFAL']
self.command = self.options.command.upper()
if self.command not in AvailableCommands:
msg = "You specified to use %s command and it is not allowed. Available commands are: %s " % (self.command, str(AvailableCommands))
ex = ConfigurationException(msg)
raise ex
else:
self.command = None
if hasattr(self.options, 'checksum'):
if re.match('^yes$|^no$', self.options.checksum):
self.checksum = 'ADLER32' if self.options.checksum == 'yes' else None
else:
msg = "You specified to use %s checksum. Only lowercase yes/no is accepted to turn ADLER32 checksum" % self.options.checksum
ex = ConfigurationException(msg)
raise ex
示例3: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
#check the format of jobids
self.jobids = ''
if getattr(self.options, 'jobids', None):
self.jobids = validateJobids(self.options.jobids)
示例4: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
Check if the sitelist parameter is a comma separater list of cms sitenames,
and put the strings to be passed to the server to self
"""
SubCommand.validateOptions(self)
#Checking if the sites provided by the user are valid cmsnames. Doing this because with only the
#server error handling we get:
# Server answered with: Invalid input parameter
# Reason is: Incorrect 'siteblacklist' parameter
#which is not really user friendly.
#Moreover, I prefer to be independent from Lexicon. I'll the regex here.
sn_re = "^T[1-3]_[A-Z]{2}(_[A-Za-z0-9]+)+$" #sn_re => SiteName_RegularExpression
sn_rec = re.compile(sn_re) #sn_rec => SiteName_RegularExpressionCompiled
self.sitewhitelist = ''
self.siteblsklist = ''
for siteList in ['sitewhitelist', 'siteblacklist']:
result = ''
paramVal = getattr(self.options, siteList, None)
if paramVal:
for site in paramVal.split(','):
if not sn_rec.match(site):
raise ConfigException("The sitename %s dows not look like a valid CMS name (not matching %s)" % (site, sn_re) )
result += "&%s=%s" % (siteList, site)
setattr(self, siteList, result)
#check the format of jobids
self.jobids = ''
if getattr(self.options, 'jobids', None):
self.jobids = validateJobids(self.options.jobids)
示例5: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
if self.options.jobid is not None:
try:
int(self.options.jobid)
except ValueError:
raise ClientException("The --jobid option has to be an integer")
示例6: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
Check if the sitelist parameter is a comma separater list of cms sitenames,
and put the strings to be passed to the server to self
"""
SubCommand.validateOptions(self)
#Checking if the sites provided by the user are valid cmsnames. Doing this because with only the
#server error handling we get:
# Server answered with: Invalid input parameter
# Reason is: Incorrect 'siteblacklist' parameter
#which is not really user friendly.
#Moreover, I prefer to be independent from Lexicon. I'll the regex here.
sn_re = "^T[1-3]_[A-Z]{2}(_[A-Za-z0-9]+)+$" #sn_re => SiteName_RegularExpression
sn_rec = re.compile(sn_re) #sn_rec => SiteName_RegularExpressionCompiled
self.sitewhitelist = ''
self.siteblsklist = ''
for siteList in ['sitewhitelist', 'siteblacklist']:
result = ''
paramVal = getattr(self.options, siteList, None)
if paramVal:
for site in paramVal.split(','):
if not sn_rec.match(site):
raise ConfigException("The sitename %s dows not look like a valid CMS name (not matching %s)" % (site, sn_re) )
result += "&%s=%s" % (siteList, site)
setattr(self, siteList, result)
#check the format of jobids
self.jobids = ''
if getattr(self.options, 'jobids', None):
self.jobids = validateJobids(self.options.jobids)
# Sanity checks for task sizes. Limits are purposely fairly generous to provide some level of future-proofing.
# The server may restrict further.
self.numcores = None
if self.options.numcores != None:
if self.options.numcores < 1 or self.options.numcores > 128:
raise ConfigException("The number of requested cores (%d) must be between 1 and 128." % (self.options.numcores))
self.numcores = str(self.options.numcores)
self.maxjobruntime = None
if self.options.maxjobruntime != None:
if self.options.maxjobruntime < 1 or self.options.maxjobruntime > 336:
raise ConfigException("The requested max job runtime (%d hours) must be between 1 and 336 hours." % self.options.maxjobruntime)
self.maxjobruntime = str(self.options.maxjobruntime)
self.maxmemory = None
if self.options.maxmemory != None:
if self.options.maxmemory < 30 or self.options.maxmemory > 1024*30:
raise ConfigException("The requested per-job memory (%d MB) must be between 30 and 30720 MB." % self.options.maxmemory)
self.maxmemory = str(self.options.maxmemory)
self.priority = None
if self.options.priority != None:
self.priority = str(self.options.priority)
示例7: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
After doing the general options validation from the parent SubCommand class,
do the validation of options that are specific to the submit command.
"""
## First do the basic validation in the SubCommand.
SubCommand.validateOptions(self)
validateSubmitOptions(self.options, self.args)
示例8: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
if self.options.sitename is None:
msg = "%sError%s: Please specify the site where to check the write permissions." % (colors.RED, colors.NORMAL)
msg += " Use the --site option."
ex = MissingOptionException(msg)
ex.missingOption = "sitename"
raise ex
示例9: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
if self.options.idle and (self.options.long or self.options.summary ):
raise ConfigurationException("Idle option (-i) conflicts with -u, and -l")
self.long = self.options.long
self.json = self.options.json
self.summary = self.options.summary
self.idle = self.options.idle
示例10: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
Check if the output file is given and set as attribute
"""
SubCommand.validateOptions(self)
if not re.match('^yes$|^no$', self.options.usedbs):
raise ConfigurationException("--dbs option only accepts the yes and no values (--dbs=yes or --dbs=no)")
self.usedbs = 1 if self.options.usedbs=='yes' else 0
setattr(self, 'outdir', getattr(self.options, 'outdir', None))
示例11: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
if self.options.idle and (self.options.long or self.options.summary):
raise ConfigurationException("Option --idle conflicts with --summary and --long")
if self.options.sort is not None:
sortOpts = ["state", "site", "runtime", "memory", "cpu", "retries", "waste", "exitcode"]
if self.options.sort not in sortOpts:
msg = "%sError%s:" % (colors.RED, colors.NORMAL)
msg += " Only the following values are accepted for --sort option: %s" % (sortOpts)
raise ConfigurationException(msg)
示例12: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
SubCommand.validateOptions(self)
if self.options.idle and (self.options.long or self.options.summary or self.options.publication):
raise ConfigurationException("Idle option (-i) conflicts with -u, -l, and -p")
if self.options.publication and (self.options.long or self.options.summary or self.options.idle):
raise ConfigurationException("Publication option (-p) conflicts with -u, -l, and -i")
self.long = self.options.long
self.json = self.options.json
self.summary = self.options.summary
self.idle = self.options.idle
self.publication = self.options.publication
示例13: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
Check if the sitelist parameter is a comma separater list of cms sitenames,
and put the strings to be passed to the server to self
"""
SubCommand.validateOptions(self)
## Check the format of the jobids option.
if getattr(self.options, 'jobids'):
jobidstuple = validateJobids(self.options.jobids)
self.jobids = [str(jobid) for (_, jobid) in jobidstuple]
#Checking if the sites provided by the user are valid cmsnames. Doing this because with only the
#server error handling we get:
# Server answered with: Invalid input parameter
# Reason is: Incorrect 'siteblacklist' parameter
#which is not really user friendly.
#Moreover, I prefer to be independent from Lexicon. I'll the regex here.
sn_re = "^T[1-3]_[A-Z]{2}(_[A-Za-z0-9]+)+$" #sn_re => SiteName_RegularExpression
sn_rec = re.compile(sn_re) #sn_rec => SiteName_RegularExpressionCompiled
for sitelist in ['sitewhitelist', 'siteblacklist']:
if getattr(self.options, sitelist) is not None:
for i, site_name in enumerate(getattr(self.options, sitelist).split(',')):
if not sn_rec.match(site_name):
msg = "The site name %s does not look like a valid CMS site name" % (site_name)
msg += " (it is not matching the regular expression %s)." % (sn_re)
raise ConfigurationException(msg)
setattr(self, sitelist, getattr(self.options, sitelist).split(','))
## Sanity checks for task sizes. Limits are purposely fairly generous to provide
## some level of future-proofing. The server may restrict further.
if self.options.maxjobruntime is not None:
if self.options.maxjobruntime < 60 or self.options.maxjobruntime > 336*60:
msg = "The requested maximum job runtime (%d minutes) must be between 60 and 20160 minutes." % (self.options.maxjobruntime)
raise ConfigurationException(msg)
self.maxjobruntime = str(self.options.maxjobruntime)
if self.options.maxmemory is not None:
if self.options.maxmemory < 30 or self.options.maxmemory > 1024*30:
msg = "The requested per-job memory (%d MB) must be between 30 and 30720 MB." % (self.options.maxmemory)
raise ConfigurationException(msg)
self.maxmemory = str(self.options.maxmemory)
if self.options.numcores is not None:
if self.options.numcores < 1 or self.options.numcores > 128:
msg = "The requested number of cores (%d) must be between 1 and 128." % (self.options.numcores)
raise ConfigurationException(msg)
self.numcores = str(self.options.numcores)
if self.options.priority is not None:
self.priority = str(self.options.priority)
示例14: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
"""
Check if the output file is given and set as attribute
"""
SubCommand.validateOptions(self)
if self.options.usedbs is not None:
msg = "CRAB command option error: the option --dbs has been deprecated since CRAB v3.3.1603."
raise UnknownOptionException(msg)
recoveryMethods = ['notFinished', 'notPublished', 'failed']
if self.options.recovery not in recoveryMethods:
msg = "%sError%s:" % (colors.RED, colors.NORMAL)
msg += " The --recovery option only accepts the following values: %s" % (recoveryMethods)
raise ConfigurationException(msg)
示例15: validateOptions
# 需要导入模块: from CRABClient.Commands.SubCommand import SubCommand [as 别名]
# 或者: from CRABClient.Commands.SubCommand.SubCommand import validateOptions [as 别名]
def validateOptions(self):
#Figuring out the destination directory
SubCommand.validateOptions(self)
self.dest = None
if self.options.outputpath is not None:
if not os.path.isabs( self.options.outputpath ):
self.dest = os.path.abspath( self.options.outputpath )
else:
self.dest = self.options.outputpath
#convert all to -1
if getattr(self.options, 'quantity', None) == 'all':
self.options.quantity = -1
#check the format of jobids
if getattr(self.options, 'jobids', None):
self.options.jobids = validateJobids(self.options.jobids)