result = dirac.selectJobs( jobGroup = value, date = jobDate, status = 'Done' ) if not result['OK']: if not "No jobs selected" in result['Message']: print "Error:", result['Message'] DIRAC.exit( -1 ) else: jobs += result['Value'] result = dirac.selectJobs( jobGroup = value, date = jobDate, status = 'Failed' ) if not result['OK']: if not "No jobs selected" in result['Message']: print "Error:", result['Message'] DIRAC.exit( -1 ) else: jobs += result['Value'] for arg in parseArguments( args ): if os.path.isdir( arg ): print "Output for job %s already retrieved, remove the output directory to redownload" % arg else: jobs.append( arg ) if not jobs: print "No jobs selected" DIRAC.exit( 0 ) if group: if outputDir: outputDir = os.path.join( outputDir, group ) else: outputDir = group
Script.registerSwitch( "D:", "Dir=", "Store the output in this directory" ) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if len( args ) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments dirac = Dirac() exitCode = 0 errorList = [] outputDir = '' for sw, v in Script.getUnprocessedSwitches(): if sw in ( 'D', 'Dir' ): outputDir = v for job in parseArguments( args ): result = dirac.getJobOutputData( job, destinationDir = outputDir ) if result['OK']: print 'Job %s output data retrieved' % ( job ) else: errorList.append( ( job, result['Message'] ) ) exitCode = 2 for error in errorList: print "ERROR %s: %s" % error DIRAC.exit( exitCode )
from DIRAC.Core.Base import Script Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1], 'Usage:', ' %s [option|cfgfile] ... JobID ...' % Script.scriptName, 'Arguments:', ' JobID: DIRAC Job ID' ] ) ) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if len( args ) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments dirac = Dirac() exitCode = 0 errorList = [] result = dirac.rescheduleJob( parseArguments( args ) ) if result['OK']: print 'Rescheduled job %s' % ','.join( [str( j ) for j in result['Value']] ) else: errorList.append( ( j, result['Message'] ) ) print result['Message'] exitCode = 2 for error in errorList: print "ERROR %s: %s" % error DIRAC.exit( exitCode )
jFile = open( value ) jobs += jFile.read().split() jFile.close() elif key.lower() in ( 'g', 'jobgroup' ): jobDate = toString( date() - 30 * day ) # Choose jobs no more than 30 days old result = dirac.selectJobs( jobGroup = value, date = jobDate ) if not result['OK']: print "Error:", result['Message'] DIRACExit( -1 ) jobs += result['Value'] if len( args ) < 1 and not jobs: Script.showHelp() if len( args ) > 0: jobs += parseArguments( args ) result = dirac.getJobStatus( jobs ) if result['OK']: for job in result['Value']: print 'JobID=' + str( job ), for status in result['Value'][job].items(): print '%s=%s;' % status, print else: exitCode = 2 print "ERROR: %s" % result['Message'] DIRAC.exit( exitCode )
######################################################################## """ Issue a kill signal to a running DIRAC job """ __RCSID__ = "$Id$" import DIRAC from DIRAC.Core.Base import Script Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1], 'Usage:', ' %s [option|cfgfile] ... JobID ...' % Script.scriptName, 'Arguments:', ' JobID: DIRAC Job ID' ] ) ) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if len( args ) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments result = Dirac().killJob( parseArguments( args ) ) if result['OK']: print 'Killed jobs %s' % ','.join( [str( j ) for j in result['Value']] ) exitCode = 0 else: print 'ERROR', result['Message'] exitCode = 2 DIRAC.exit( exitCode )
Script.registerSwitch("D:", "Dir=", "Store the output in this directory") Script.parseCommandLine(ignoreErrors=True) args = Script.getPositionalArgs() if len(args) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments dirac = Dirac() exitCode = 0 errorList = [] outputDir = '' for sw, v in Script.getUnprocessedSwitches(): if sw in ('D', 'Dir'): outputDir = v for job in parseArguments(args): result = dirac.getJobOutputData(job, destinationDir=outputDir) if result['OK']: print 'Job %s output data retrieved' % (job) else: errorList.append((job, result['Message'])) exitCode = 2 for error in errorList: print "ERROR %s: %s" % error DIRAC.exit(exitCode)
if "No jobs selected" not in result['Message']: print("Error:", result['Message']) DIRAC.exit(-1) else: jobs += result['Value'] result = dirac.selectJobs(jobGroup=value, date=jobDate, status='Failed') if not result['OK']: if "No jobs selected" not in result['Message']: print("Error:", result['Message']) DIRAC.exit(-1) else: jobs += result['Value'] for arg in parseArguments(args): if os.path.isdir(arg): print( "Output for job %s already retrieved, remove the output directory to redownload" % arg) else: jobs.append(arg) if not jobs: print("No jobs selected") DIRAC.exit(0) if group: if outputDir: outputDir = os.path.join(outputDir, group) else:
""" Issue a kill signal to a running DIRAC job """ from __future__ import print_function __RCSID__ = "$Id$" import DIRAC from DIRAC.Core.Base import Script Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1], 'Usage:', ' %s [option|cfgfile] ... JobID ...' % Script.scriptName, 'Arguments:', ' JobID: DIRAC Job ID' ] ) ) Script.parseCommandLine( ignoreErrors = True ) args = Script.getPositionalArgs() if len( args ) < 1: Script.showHelp() from DIRAC.Interfaces.API.Dirac import Dirac, parseArguments result = Dirac().killJob( parseArguments( args ) ) if result['OK']: print('Killed jobs %s' % ','.join([str(j) for j in result['Value']])) exitCode = 0 else: print('ERROR', result['Message']) exitCode = 2 DIRAC.exit( exitCode )
jFile = open(value) jobs += jFile.read().split() jFile.close() elif key.lower() in ('g', 'jobgroup'): jobDate = toString(date() - 30 * day) # Choose jobs no more than 30 days old result = dirac.selectJobs(jobGroup=value, date=jobDate) if not result['OK']: print("Error:", result['Message']) DIRACExit(-1) jobs += result['Value'] if len(args) < 1 and not jobs: Script.showHelp() if len(args) > 0: jobs += parseArguments(args) result = dirac.getJobStatus(jobs) if result['OK']: for job in result['Value']: print('JobID=' + str(job), end=' ') for status in result['Value'][job].items(): print('%s=%s;' % status, end=' ') print() else: exitCode = 2 print("ERROR: %s" % result['Message']) DIRAC.exit(exitCode)