def validateOptions(self): """ __validateOptions__ Validate the command line options of the command. Raise a ConfigurationException in case of error; don't do anything if ok. """ if self.cmdconf['requiresTaskOption'] and self.options.task is None: if len(self.args) > 1: msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " 'crab %s' command accepts at most 1 argument (a path to a CRAB project directory), %d given." % (self.name, len(self.args)) raise ConfigurationException(msg) elif len(self.args) == 1 and self.args[0]: self.options.task = self.args.pop(0) elif self.cmdconf['useCache'] and self.crab3dic.get('crab_project_directory'): self.options.task = str(self.crab3dic['crab_project_directory']) if self.options.task is None: msg = "%sError%s: Directory option is required." % (colors.RED, colors.NORMAL) ex = MissingOptionException(msg) ex.missingOption = "task" raise ex ## If the command does not take any arguments, but some arguments were passed, ## clear the arguments list and give a warning message saying that the given ## arguments will be ignored. if not self.cmdconf['acceptsArguments'] and len(self.args): msg = "%sWarning%s:" % (colors.RED, colors.NORMAL) msg += " 'crab %s' command takes no arguments, %d given." % (self.name, len(self.args)) msg += " Ignoring arguments %s." % (self.args) self.logger.warning(msg) self.args = []
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
def validateOptions(self): getcommand.validateOptions(self) if self.options.short: if self.options.jobids is None: msg = "%sError%s: Please specify the job ids for which to retrieve the logs." % (colors.GREEN, colors.NORMAL) msg += " Use the --jobids option." ex = MissingOptionException(msg) ex.missingOption = "jobids" raise ex
def validateOptions(self): getcommand.validateOptions(self) if self.options.short: if self.options.jobids is None: msg = "%sError%s: Please specify the job ids for which to retrieve the logs." % (colors.GREEN, colors.NORMAL) msg += " Use the --jobids option." ex = MissingOptionException(msg) ex.missingOption = "jobids" raise ex
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
def validateOptions(self): ## Do the options validation from SubCommand. try: SubCommand.validateOptions(self) except MissingOptionException as ex: if ex.missingOption == "task": msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Please provide a path to a CRAB project directory (use the -d/--dir option)" msg += " or to a log file (use the --logpath option)." ex = MissingOptionException(msg) ex.missingOption = "task" raise ex
def validateOptions(self): if self.options.cmptask is None: msg = "%sError%s: Please specify the task name for which to remake a CRAB project directory." % (colors.RED, colors.NORMAL) msg += " Use the --task option." ex = MissingOptionException(msg) ex.missingOption = "cmptask" raise ex else: regex = "^\d{6}_\d{6}_?([^\:]*)\:[a-zA-Z-]+_(crab_)?.+" if not re.match(regex, self.options.cmptask): msg = "%sError%s: Task name does not match the regular expression '%s'." % (colors.RED, colors.NORMAL, regex) raise ConfigurationException(msg)
def validateOptions(self): if self.options.cmptask is None: msg = "%sError%s: Please specify the task name for which to remake a CRAB project directory." % (colors.RED, colors.NORMAL) msg += " Use the --task option." ex = MissingOptionException(msg) ex.missingOption = "cmptask" raise ex else: regex = "^\d{6}_\d{6}_?([^\:]*)\:[a-zA-Z-]+_(crab_)?.+" if not re.match(regex, self.options.cmptask): msg = "%sError%s: Task name does not match the regular expression '%s'." % (colors.RED, colors.NORMAL, regex) raise ConfigurationException(msg)
def validateOptions(self): """ __validateOptions__ Validate the command line options of the command. Raise a ConfigurationException in case of error; don't do anything if ok. """ if self.cmdconf['requiresDirOption']: if self.options.projdir is None: if len(self.args) > 1: msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " 'crab %s' command accepts at most 1 argument (a path to a CRAB project directory), %d given." % ( self.name, len(self.args)) raise ConfigurationException(msg) elif len(self.args) == 1 and self.args[0]: self.options.projdir = self.args.pop(0) elif self.cmdconf['useCache'] and self.crab3dic.get( 'crab_project_directory'): self.options.projdir = str( self.crab3dic['crab_project_directory']) if self.options.projdir is None: msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Please indicate the CRAB project directory with --dir=<project-directory>." ex = MissingOptionException(msg) ex.missingOption = "task" raise ex if not os.path.isdir(self.options.projdir): msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " %s is not a valid CRAB project directory." % ( self.options.projdir) raise ConfigurationException(msg) ## If an input project directory was given, load the request cache and take the ## server URL from it. self.loadLocalCache() ## If the command does not take any arguments, but some arguments were passed, ## clear the arguments list and give a warning message saying that the given ## arguments will be ignored. if not self.cmdconf['acceptsArguments'] and len(self.args): msg = "%sWarning%s:" % (colors.RED, colors.NORMAL) msg += " 'crab %s' command takes no arguments, %d given." % ( self.name, len(self.args)) msg += " Ignoring arguments %s." % (self.args) self.logger.warning(msg) self.args = []
def validateOptions(self): """ __validateOptions__ Validate the command line options of the command. Raise a ConfigurationException in case of error; don't do anything if ok. """ if self.cmdconf['requiresDirOption']: if self.options.projdir is None: if len(self.args) > 1: msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " 'crab %s' command accepts at most 1 argument (a path to a CRAB project directory), %d given." % (self.name, len(self.args)) raise ConfigurationException(msg) elif len(self.args) == 1 and self.args[0]: self.options.projdir = self.args.pop(0) elif self.cmdconf['useCache'] and self.crab3dic.get('crab_project_directory'): self.options.projdir = str(self.crab3dic['crab_project_directory']) if self.options.projdir is None: msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Please indicate the CRAB project directory with --dir=<project-directory>." ex = MissingOptionException(msg) ex.missingOption = "task" raise ex if not os.path.isdir(self.options.projdir): msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " %s is not a valid CRAB project directory." % (self.options.projdir) raise ConfigurationException(msg) ## If an input project directory was given, load the request cache and take the ## server URL from it. self.loadLocalCache() ## If the command does not take any arguments, but some arguments were passed, ## clear the arguments list and give a warning message saying that the given ## arguments will be ignored. if not self.cmdconf['acceptsArguments'] and len(self.args): msg = "%sWarning%s:" % (colors.RED, colors.NORMAL) msg += " 'crab %s' command takes no arguments, %d given." % (self.name, len(self.args)) msg += " Ignoring arguments %s." % (self.args) self.logger.warning(msg) self.args = []
def validateOptions(self): if self.options.cmptask is None: raise MissingOptionException( "%sError%s: Please use the --task option to specify the task name." % (colors.RED, colors.NORMAL)) else: regex = "^\d{6}_\d{6}_?([^\:]*)\:[a-zA-Z-]+_(crab_)?.+" if not re.match(regex, self.options.cmptask): msg = "%sError%s: Task name does not match the regular expression '%s'." % ( colors.RED, colors.NORMAL, regex) raise ConfigurationException(msg)
def validateOptions(self): ## Check if the --logpath option was used. If it was, don't require the task ## option. if self.options.logpath is not None: if not os.path.isfile(self.options.logpath): msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Could not find the log file %s." % (self.options.logpath) raise ConfigurationException(msg) self.cmdconf["requiresDirOption"] = False ## Do the options validation from SubCommand. try: SubCommand.validateOptions(self) except MissingOptionException as ex: if ex.missingOption == "task": msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Please provide a path to a CRAB project directory (use the -d/--dir option)" msg += " or to a log file (use the --logpath option)." ex = MissingOptionException(msg) ex.missingOption = "task" raise ex
def validateOptions(self): ## Check if the --logpath option was used. If it was, don't require the task ## option. if self.options.logpath is not None: if not os.path.isfile(self.options.logpath): msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Could not find the log file %s." % ( self.options.logpath) raise ConfigurationException(msg) self.cmdconf['requiresDirOption'] = False ## Do the options validation from SubCommand. try: SubCommand.validateOptions(self) except MissingOptionException as ex: if ex.missingOption == "task": msg = "%sError%s:" % (colors.RED, colors.NORMAL) msg += " Please provide a path to a CRAB project directory (use the -d/--dir option)" msg += " or to a log file (use the --logpath option)." ex = MissingOptionException(msg) ex.missingOption = "task" raise ex
def validateOptions(self): """ __validateOptions__ Validate the command line options of the command. Raise a ConfigurationException in case of error; don't do anything if ok. """ if self.cmdconf[ 'requiresTaskOption'] and self.options.oldtask is not None: msg = "CRAB command line option error: the option -t/--task has been renamed to -d/--dir." raise UnknownOptionException(msg) if self.cmdconf['requiresTaskOption'] and self.options.task is None: if len(self.args) == 1 and self.args[0]: self.options.task = self.args[0] elif self.cmdconf['useCache'] and self.crab3dic['taskname'] != None: self.options.task = self.crab3dic['taskname'] else: raise MissingOptionException('ERROR: Task option is required.')