예제 #1
0
def processScriptSwitches():
  
  global vo, dry, doCEs, doSEs
  
  Script.registerSwitch( "V:", "vo=", "Virtual Organization" )
  Script.registerSwitch( "D", "dry", "Dry run" )
  Script.registerSwitch( "C", "ce", "Process Computing Elements" )
  Script.registerSwitch( "S", "se", "Process Storage Elements" )
  
  Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       'Usage:',
                                       '  %s [option|cfgfile]' % Script.scriptName ] ) )
  Script.parseCommandLine( ignoreErrors = True )
  
  vo = ''
  dry = False
  doCEs = False
  doSEs = False
  for sw in Script.getUnprocessedSwitches():
    if sw[0] in ( "V", "vo" ):
      vo = sw[1]    
    if sw[0] in ( "D", "dry" ):
      dry = True  
    if sw[0] in ( "C", "ce" ):
      doCEs = True    
    if sw[0] in ( "S", "se" ):
      doSEs = True    
예제 #2
0
def processScriptSwitches():

  global vo, dry, doCEs, doSEs, hostURL, glue2

  Script.registerSwitch("V:", "vo=", "Virtual Organization")
  Script.registerSwitch("D", "dry", "Dry run")
  Script.registerSwitch("C", "ce", "Process Computing Elements")
  Script.registerSwitch("S", "se", "Process Storage Elements")
  Script.registerSwitch("H:", "host=", "use this url for information querying")
  Script.registerSwitch("G", "glue2", "query GLUE2 information schema")

  Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                    'Usage:',
                                    '  %s [option|cfgfile]' % Script.scriptName]))
  Script.parseCommandLine(ignoreErrors=True)

  vo = ''
  dry = False
  doCEs = False
  doSEs = False
  hostURL = None
  glue2 = False
  for sw in Script.getUnprocessedSwitches():
    if sw[0] in ("V", "vo"):
      vo = sw[1]
    if sw[0] in ("D", "dry"):
      dry = True
    if sw[0] in ("C", "ce"):
      doCEs = True
    if sw[0] in ("S", "se"):
      doSEs = True
    if sw[0] in ("H", "host"):
      hostURL = sw[1]
    if sw[0] in ("G", "glue2"):
      glue2 = True
예제 #3
0
 def registerCLISwitches( self ):
   """
   add options to dirac option parser
   """
   Script.setUsageMessage( "Script to delete a dirac proxy. Default: delete local proxy only." )
   Script.registerSwitch( "a", "all", "Delete the local and all uploaded proxies (the nuclear option)", self.setDeleteAll )
   Script.registerSwitch( "v:", "vo=", "Delete uploaded proxy for vo name given", self.addVO )
 def registerSwitchs(self):
   Script.registerSwitch("T:", "To=", "mail To", self.setTo)
   Script.registerSwitch("F:","From=","mail from", self.setFrom)
   Script.registerSwitch("S:","Subject=","mail Subject",self.setSubject)
   Script.registerSwitch("B:","Body=","mail Body",self.setBody)
   Script.registerSwitch("f:","File=","Body content file",self.setFileName)
   Script.setUsageMessage( '$s -T [email protected] -F [email protected] -S subject -B "My Body\n is ace"' )
예제 #5
0
 def registerSwitches(self):
   Script.registerSwitch('P:', "Platform=", 'Platform to use', self.setPlatform)
   Script.registerSwitch('p:', "Path=", "Path to the Whizard results directory", self.setPath)
   Script.registerSwitch("V:", "Version=", "Whizard version", self.setVersion)
   Script.registerSwitch('b:', 'BeamSpectra=', 'Beam spectra version', self.setBeamSpectra)
   Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                        '\nUsage:',
                                        '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
예제 #6
0
def registerUsageMessage():
    """
    Takes the script __doc__ and adds the DIRAC version to it
  """

    usageMessage = "DIRAC version: %s \n" % version
    usageMessage += __doc__

    Script.setUsageMessage(usageMessage)
 def registerSwitches(self):
   Script.registerSwitch("P:", "Platform=", "Platform ex. %s" % self.platform, self.setPlatform)
   Script.registerSwitch("N:", "Name=", "Application name", self.setName)
   Script.registerSwitch("V:", "Version=", "Version", self.setVersion)
   Script.registerSwitch("T:", "TarBall=", "Tar ball location", self.setTarBall)
   Script.registerSwitch("C:", "Comment=", "Comment", self.setComment)
   Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                        '\nUsage:',
                                        '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
예제 #8
0
 def registerSwitches(self):
   Script.registerSwitch("U:", "UserName="******"DIRAC user name", self.setUName)
   Script.registerSwitch("G:","Groups=","DIRAC groups in which to add the new user, comma separated", self.setGroup)
   Script.registerSwitch("D:","DN=","user DN",self.setDN)
   Script.registerSwitch("C:","CN=","user CN (or CA)",self.setCN)
   Script.registerSwitch("E:","Email=","User mail",self.setEmail)
   Script.registerSwitch("","CCID=","CERN CC user ID (if any)", self.setCERNID)
   Script.registerSwitch("X", "external", "set if user is external, no checking of the PhoneBook", self.setExternal)
   Script.setUsageMessage("""%s -U <username> -G <ilc_user,private_pilot,...> -D"<DN>" -C"<CN>" -E <email>""" % Script.scriptName)
def registerUsageMessage():
  '''
    Takes the script __doc__ and adds the DIRAC version to it
  '''

  usageMessage = 'DIRAC version: %s \n' % version
  usageMessage += __doc__

  Script.setUsageMessage( usageMessage )
예제 #10
0
 def registerSwitch(self):
   """registers switches"""
   Script.registerSwitch('D:', 'LogFileDir=', 'Production log dir to download', self.setLogFileD)
   Script.registerSwitch('F:', 'LogFile=', 'Production log to download', self.setLogFileF)
   Script.registerSwitch('O:', 'OutputDir=', 'Output directory (default %s)' % self.outputdir, 
                         self.setOutputDir)
   Script.registerSwitch('P:', 'ProdID=', 'Production ID', self.setProdID)
   Script.registerSwitch('A', 'All', 'Get logs from all sub-directories', self.setAllGet)
   Script.registerSwitch('N', 'NoPrompt', 'No prompt before download', self.setNoPrompt)
   Script.setUsageMessage('%s -F /ilc/prod/.../LOG/.../somefile' % Script.scriptName)
 def registerSwitch(self):
   """ Register all CLI switches
   """
   Script.registerSwitch("P:", "prods=", "Productions: greater than with gt1234, range with 32-56, list with 34,56", self.setProdID)
   Script.registerSwitch("p", "precise_detail", "Precise detail, slow", self.setFullDetail)
   Script.registerSwitch("v", "verbose", "Verbose output", self.setVerbose)
   Script.registerSwitch("t:", "types=", "Production Types, comma separated, default all", self.setProdTypes)
   Script.registerSwitch("S:", "Statuses=", "Statuses, comma separated, default all", self.setStatuses)
   Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       '\nUsage:',
                                       '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
예제 #12
0
def registerUsageMessage():
    """
  Takes the script __doc__ and adds the DIRAC version to it
  """

    hLine = "  " + "=" * 78 + "\n"

    usageMessage = hLine
    usageMessage += "  DIRAC %s\n" % version
    usageMessage += __doc__
    usageMessage += "\n" + hLine

    Script.setUsageMessage(usageMessage)
예제 #13
0
def registerUsageMessage():
  '''
    Takes the script __doc__ and adds the DIRAC version to it
  '''

  hLine = '  ' + '='*78 + '\n'
  
  usageMessage = hLine
  usageMessage += '  DIRAC %s\n' % version
  usageMessage += __doc__
  usageMessage += '\n' + hLine
  
  Script.setUsageMessage( usageMessage )
예제 #14
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  Script.registerSwitch("H:", "host=", "BDII host")
  Script.registerSwitch("V:", "vo=", "vo")
  Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                    'Usage:',
                                    '  %s [option|cfgfile] ... <info> <Site|CE>' % Script.scriptName,
                                    'Arguments:',
                                    '  Site:     Name of the Site (i.e. CERN-PROD)',
                                    '  CE:       Name of the CE (i.e. cccreamceli05.in2p3.fr)',
                                    '  info:     Accepted values (ce|ce-state|ce-cluster|ce-vo|site|site-se)']))
  def registerSwitches(self):
    Script.registerSwitch("P:", "Platform=", "Platform ex. %s" % self.platform, self.setPlatform)
    Script.registerSwitch("A:", "Applications=", "Comma separated list of applications", self.setName)
    Script.registerSwitch("V:", "Version=", "Version name", self.setVersion)
    Script.registerSwitch("C:", "Comment=", "Comment", self.setComment)
    Script.registerSwitch("S:", "Script=", "Full path to initScript", self.setInitScript)
    Script.registerSwitch("B:", "Base=", "Path to Installation Base", self.setBasePath)

    Script.registerSwitch("O:", "ILDConfig=", "Path To ILDConfig (if it is in ApplicationPath)", self.setILDConfig)

    Script.registerSwitch("Q:", "DBSlice=", "Path to Mokka DB Slice", self.setDBSlice)


    Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                         '\nUsage:',
                                         '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
  def _setSwitches(self):
    Script.registerSwitch("S:", "system=", "Systems to check, by default all of them are checked", self._setSystems)
    Script.registerSwitch("M", "modified", "Show entries which differ from the default", self._setShowModified)
    Script.registerSwitch("A", "added", "Show entries which do not exist in ConfigTemplate", self._setShowAdded)
    Script.registerSwitch("U", "missingSection", "Show sections which do not exist in the current configuration",
                          self._setShowMissingSections)
    Script.registerSwitch("O", "missingOption", "Show options which do not exist in the current configuration",
                          self._setShowMissingOptions)

    Script.setUsageMessage('\n'.join([self.__doc__,
                                      'Usage:',
                                      '  %s [option|cfgfile] -[MAUO] [-S <system]' % Script.scriptName]))
    Script.parseCommandLine(ignoreErrors=True)
    if not any([self.showModified, self.showAdded, self.showMissingSections, self.showMissingOptions]):
      LOG.error("\nERROR: Set at least one of the flags M A U O")
      Script.showHelp()
예제 #17
0
  def registerSwitches( self ):
    Script.registerSwitch( "r:", "releases=", "releases to build (mandatory, comma separated)", cliParams.setReleases )
    Script.registerSwitch( "l:", "project=", "Project to build the release for (DIRAC by default)", cliParams.setProject )
    Script.registerSwitch( "D:", "destination", "Destination where to build the tar files", cliParams.setDestination )
    Script.registerSwitch( "i:", "pythonVersion", "Python version to use (25/26)", cliParams.setPythonVersion )
    Script.registerSwitch( "P", "ignorePackages", "Do not make tars of python packages", cliParams.setIgnorePackages )
    Script.registerSwitch( "C:", "relcfg=", "Use <file> as the releases.cfg", cliParams.setReleasesCFG )
    Script.registerSwitch( "b", "buildExternals", "Force externals compilation even if already compiled", cliParams.setForceExternals )
    Script.registerSwitch( "B", "ignoreExternals", "Skip externals compilation", cliParams.setIgnoreExternals )
    Script.registerSwitch( "t:", "buildType=", "External type to build (client/server)", cliParams.setExternalsBuildType )
    Script.registerSwitch( "x:", "externalsLocation=", "Use externals location instead of downloading them", cliParams.setExternalsLocation )
    Script.registerSwitch( "j:", "makeJobs=", "Make jobs (default is 1)", cliParams.setMakeJobs )

    Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                        '\nUsage:',
                                        '  %s [option|cfgfile] ...\n' % Script.scriptName ] ) )
예제 #18
0
 def registerSwitches(self):
   """ Register the switches
   """
   Script.registerSwitch("", "submitmode=", "Submission mode: local or WMS", self.setSubmitMode)
   Script.registerSwitch('', 'whizard', "Test Whizard", self.setTestWhizard)
   Script.registerSwitch("", "mokka", 'Test Mokka', self.setTestMokka)
   Script.registerSwitch("", "marlin", 'Test Marlin', self.setTestMarlin)
   Script.registerSwitch("", "slic", 'Test SLIC', self.setTestSLIC)
   Script.registerSwitch("", "lcsim", "Test LCSIM", self.setTestLCSIM)
   Script.registerSwitch("", "slicpandora", 'Test SLICPandora', self.setTestSlicPandora)
   Script.registerSwitch("", 'overlay', "Test the overlay", self.setTestOverlay)
   Script.registerSwitch("", 'inputdata', "Test the InputData resolution", self.setTestInputData)
   Script.registerSwitch("", "utilities", "Test the utilities: cut, split, concatenate", self.setTestUtilities)
   Script.registerSwitch("", 'root', 'Test the root application', self.setTestRoot)
   Script.registerSwitch("", 'chain', 'Test the chaining of applications', self.setTestChain)
   Script.registerSwitch("", 'nocleanup', 'Do not clean the tmp directories', self.setNoCleanup)
   Script.registerSwitch("a", "all", "Test them ALL!", self.setTestAll)
   Script.setUsageMessage("%s --all --submitmode=local" % Script.scriptName)
예제 #19
0
 def registerSwitches(self):
   Script.registerSwitch('P:', 'Path=', 'Path where the file(s) are (directory or single file)', self.setDir)
   Script.registerSwitch('S:', "SE=", 'Storage element(s) to use ex: DESY-SRM', self.setSE)
   Script.registerSwitch('M:', "MachineParams=", 'Machine Parameters, default: %s' % self.machineParams, 
                         self.setMachineParams)
   Script.registerSwitch("E:", "Energy=", "Energy in GeV, e.g. 1000", self.setEnergy)
   Script.registerSwitch("I:", "EvtID=","Process ID, like 35945",self.setProcessID)
   Script.registerSwitch("C:", "EvtClass=","Process class, like 6f_ttbar",self.setEvtClass)
   Script.registerSwitch("T:", "EvtType=",'Process type, like 6f_yyyyee',self.setEvtType)
   Script.registerSwitch("L:", "Luminosity=",'Luminosity of the sample',self.setLumi)
   Script.registerSwitch("N:", "NumberOfEvents=",'Number of events per file',self.setNumberOfEvents)
   Script.registerSwitch('', 'BeamParticle1=', 'Particle of beam 1, e.g. e1', self.setBeamP1 )
   Script.registerSwitch('', 'BeamParticle2=', 'Particle of beam 2, e.g. E1', self.setBeamP2 )
   Script.registerSwitch('', 'PolarisationBeam1=', 'Polarisation for particle of beam 1: L, R, W', self.setPol1 )
   Script.registerSwitch('', 'PolarisationBeam2=', 'Polarisation for particle of beam 2: L, R, W', self.setPol2 )
   Script.registerSwitch('', 'XSection=', 'Cross section in fb' , self.setXSec)
   Script.registerSwitch('', 'XSectionError=', 'Cross section error in fb', self.setXSecE )
   Script.registerSwitch('', 'Software=', "Software and version, e.g. %s"%self.software, self.setSoftware)
   Script.registerSwitch('f', 'force', "Do not stop for confirmation", self.setForce)
   Script.setUsageMessage('\n%s -P /some/path/ -E 1000 -M B1b_ws -I 35945 etc.\n' % Script.scriptName)  
예제 #20
0
def registerSwitches():
  '''
    Registers all switches that can be used while calling the script from the
    command line interface.
  '''

  # Some of the switches have associated a callback, defined on Params class.
  cliParams = Params()

  switches = [
      ('', 'text=', 'Text to be printed'),
      ('u', 'upper', 'Print text on upper case'),
      ('r', 'showRaw', 'Show raw result from the query', cliParams.setRawResult),
      ('p:', 'numPings=', 'Number of pings to do (by default 1)', cliParams.setNumOfPingsToDo)
  ]

  # Register switches
  for switch in switches:
    Script.registerSwitch(*switch)

  # Define a help message
  Script.setUsageMessage(__doc__)
예제 #21
0
########################################################################
# $HeadURL$
# File :    dirac-admin-delete-user
# Author :  Adrian Casajus
########################################################################
"""
  Remove User from Configuration
"""
from __future__ import print_function
__RCSID__ = "$Id$"

from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... User ...' % Script.scriptName, 'Arguments:',
    '  User:     User name'
]))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

from DIRAC import exit as DIRACExit
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
diracAdmin = DiracAdmin()
exitCode = 0
errorList = []

if len(args) < 1:
    Script.showHelp()

choice = raw_input("Are you sure you want to delete user/s %s? yes/no [no]: " %
예제 #22
0
            return S_ERROR("Number of pings to do has to be a number")
        return S_OK()


# Instantiate the params class
cliParams = Params()

# Register accepted switches and their callbacks
Script.registerSwitch("r", "showRaw", "show raw result from the query",
                      cliParams.setRawResult)
Script.registerSwitch("p:", "numPings=",
                      "Number of pings to do (by default 1)",
                      cliParams.setNumOfPingsToDo)

# Define a help message
Script.setUsageMessage('\n'.join([
    __doc__, 'Usage:',
    '  %s [option|cfgfile] <system name to ping>+' % Script.scriptName,
    '  Specifying a system is mandatory'
]))

# Parse the command line and initialize DIRAC
Script.parseCommandLine(ignoreErrors=False)

# Get the list of services
servicesList = Script.getPositionalArgs()

# Check and process the command line switches and options
if len(servicesList) == 0:
    Script.showHelp()
    exit(1)
예제 #23
0
__RCSID__ = "$Id$"

from DIRAC.Core.Base import Script
from DIRAC import exit as DIRACExit, gLogger
from DIRAC.ConfigurationSystem.Client.Helpers.Resources import getDIRACSiteName
from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI


if __name__ == "__main__":

  Script.setUsageMessage(
      '\n'.join(
          [
              __doc__.split('\n')[1],
              'Usage:',
              '  %s [option|cfgfile] ... DIRACSiteName GridSiteName CE [CE] ...' %
              Script.scriptName,
              'Arguments:',
              '  DIRACSiteName: Name of the site for DIRAC in the form GRID.LOCATION.COUNTRY (ie:LCG.CERN.ch)',
              '  GridSiteName: Name of the site in the Grid (ie: CERN-PROD)',
              '  CE: Name of the CE to be included in the site (ie: ce111.cern.ch)']))
  Script.parseCommandLine(ignoreErrors=True)
  args = Script.getPositionalArgs()

  if len(args) < 3:
    Script.showHelp(exitCode=1)

  diracSiteName = args[0]
  gridSiteName = args[1]
  ces = args[2:]
  try:
예제 #24
0
"""
  Remove Site from Active mask for current Setup
"""
from __future__ import print_function

__RCSID__ = "$Id$"

import time

from DIRAC import exit as DIRACExit, gConfig, gLogger
from DIRAC.Core.Base import Script

Script.registerSwitch("E:", "email=", "Boolean True/False (True by default)")
Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s [option|cfgfile] ... Site Comment' % Script.scriptName,
                                  'Arguments:',
                                  '  Site:     Name of the Site',
                                  '  Comment:  Reason of the action']))
Script.parseCommandLine(ignoreErrors=True)

from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations
from DIRAC.Core.Utilities.PromptUser import promptUser
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin


def getBoolean(value):
  if value.lower() == 'true':
    return True
  elif value.lower() == 'false':
    return False
  else:
from DIRAC.Core.Base import Script

Script.registerSwitch("", "Status=", "Primary status")
Script.registerSwitch("", "MinorStatus=", "Secondary status")
Script.registerSwitch("", "ApplicationStatus=", "Application status")
Script.registerSwitch("", "Site=", "Execution site")
Script.registerSwitch("", "Owner=", "Owner (DIRAC nickname)")
Script.registerSwitch("", "JobGroup=", "Select jobs for specified job group")
Script.registerSwitch(
    "", "Date=",
    "Date in YYYY-MM-DD format, if not specified default is today")
Script.registerSwitch("", "File=",
                      "File name,if not specified default is std.out ")
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... String ...' % Script.scriptName, 'Arguments:',
    '  String:   string to search for'
]))

Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

#Default values
status = None
minorStatus = None
appStatus = None
site = None
owner = None
jobGroup = None
date = None
filename = 'std.out'
# pylint: disable=wrong-import-position

from DIRAC import exit as DIRACExit
from DIRAC.Core.Base import Script

extendedPrint = False


def setExtendedPrint(_arg):
  global extendedPrint
  extendedPrint = True


Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s [option|cfgfile] ... PilotID ...' % Script.scriptName,
                                  'Arguments:',
                                  '  PilotID:  Grid ID of the pilot']))
Script.registerSwitch('e', 'extended', 'Get extended printout', setExtendedPrint)
Script.parseCommandLine(ignoreErrors=True)

from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin
from DIRAC.Interfaces.API.Dirac import Dirac

args = Script.getPositionalArgs()

if len(args) < 1:
  Script.showHelp()


diracAdmin = DiracAdmin()
예제 #27
0
########################################################################
# $HeadURL$
# File :    dirac-dms-replicate-lfn
# Author  : Stuart Paterson
########################################################################
"""
  Replicate an existing LFN to another Storage Element
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... LFN Dest [Source [Cache]]' % Script.scriptName,
    'Arguments:', '  LFN:      Logical File Name or file containing LFNs',
    '  Dest:     Valid DIRAC SE', '  Source:   Valid DIRAC SE',
    '  Cache:    Local directory to be used as cache'
]))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

if len(args) < 2 or len(args) > 4:
    Script.showHelp()

lfn = args[0]
seName = args[1]
sourceSE = ''
localCache = ''
if len(args) > 2:
    sourceSE = args[2]
예제 #28
0
#!/usr/bin/env python
"""
Create a new DB on the local MySQL server
"""
# Script initialization and parseCommandLine
from DIRAC.Core.Base import Script
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgFile] ... DB ...' % Script.scriptName,
                                     'Arguments:',
                                     '  DB: Name of the Database (mandatory)'] ) )
Script.parseCommandLine()
args = Script.getPositionalArgs()
if len( args ) < 1:
  Script.showHelp()
  exit( -1 )

# Script imports
from DIRAC import gConfig
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
from DIRAC.FrameworkSystem.Utilities import MonitoringUtilities

__RCSID__ = "$Id$"

gComponentInstaller.exitOnError = True
gComponentInstaller.getMySQLPasswords()
for db in args:
  result = gComponentInstaller.installDatabase( db )
  if not result['OK']:
    print "ERROR: failed to correctly install %s" % db, result['Message']
  else:
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-dms-remove-lfn-replica
# Author :  Stuart Paterson
########################################################################
"""
  Remove replica of LFN from specified Storage Element and File catalogs.
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... LFN SE' % Script.scriptName,
                                     'Arguments:',
                                     '  LFN:      Logical File Name or file containing LFNs',
                                     '  SE:       Valid DIRAC SE' ] ) )
Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

if len( args ) < 2:
  Script.showHelp()

if len( args ) > 2:
  print 'Only one LFN SE pair will be considered'

from DIRAC.Interfaces.API.Dirac                       import Dirac
dirac = Dirac()
exitCode = 0
# File :    dirac-admin-bdii-ce-state
# Author :  Adria Casajus
########################################################################
"""
  Check info on BDII for CE state
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base                                         import Script
from DIRAC.ConfigurationSystem.Client.Helpers                import getVO

Script.registerSwitch( "H:", "host=", "BDII host" )
Script.registerSwitch( "V:", "vo=", "vo" )
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... CE' % Script.scriptName,
                                     'Arguments:',
                                     '  CE:       Name of the CE(ie: ce111.cern.ch)'] ) )

Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

from DIRAC.Interfaces.API.DiracAdmin                         import DiracAdmin

if not len( args ) == 1:
  Script.showHelp()

ce = args[0]

host = None
vo = getVO( 'lhcb' )
########################################################################
# $HeadURL$
# File :    dirac-production-job-get-input
# Author :  Stuart Paterson
########################################################################
"""
  Retrieve input sandbox for DIRAC Job
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script
import os

Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... JobID ...' % Script.scriptName,
                                     'Arguments:',
                                     '  JobID:    DIRAC Job ID' ] ) )
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
dirac = Dirac()
exitCode = 0
errorList = []

outputDir = None
예제 #32
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-fix-mysql-script
# Author :  Ricardo Graciani
########################################################################
"""
Fixes the mysql.server script, it requires a proper /LocalInstallation section
"""
__RCSID__ = "$Id$"
#
from DIRAC.Core.Base import Script
Script.disableCS()
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option] ... [cfgfile]' % Script.scriptName
]))

Script.addDefaultOptionValue('/DIRAC/Security/UseServerCertificate', 'yes')
Script.addDefaultOptionValue('LogLevel', 'INFO')
Script.parseCommandLine()
from DIRAC.Core.Utilities import InstallTools
#
InstallTools.exitOnError = True
#
result = InstallTools.fixMySQLScripts()
if not result['OK']:
    print "ERROR:", result['Message']
    exit(-1)
예제 #33
0
from DIRAC.ConfigurationSystem.Client.Helpers import getCSExtensions
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
#
from DIRAC import gConfig
from DIRAC import exit as DIRACexit

__RCSID__ = "$Id$"

gComponentInstaller.exitOnError = True
#
from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... ComponentType System Component|System/Component'
    % Script.scriptName, 'Arguments:',
    '  ComponentType:  Name of the ComponentType (ie: agent)',
    '  System:  Name of the DIRAC system (ie: WorkloadManagement)',
    '  component:   Name of the DIRAC component (ie: JobCleaningAgent)'
]))
Script.parseCommandLine()
args = Script.getPositionalArgs()

componentType = args[0]

if len(args) == 2:
    system, component = args[1].split('/')
else:
    system = args[1]
    component = args[2]

result = gComponentInstaller.addDefaultOptionsToCS(gConfig,
예제 #34
0
# File :    dirac-wms-job-submit
# Author :  Stuart Paterson
########################################################################
"""
  Submit jobs to DIRAC WMS
"""
from __future__ import print_function
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base import Script

import os

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... JDL ...' % Script.scriptName, 'Arguments:',
    '  JDL:      Path to JDL file'
]))

Script.registerSwitch("f:", "File=", "Writes job ids to file <value>")
Script.registerSwitch("r:", "UseJobRepo=", "Use the job repository")
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

if len(args) < 1:
    Script.showHelp()

from DIRAC.Interfaces.API.Dirac import Dirac
unprocessed_switches = Script.getUnprocessedSwitches()
use_repo = False
repo_name = ""
예제 #35
0
""" EvnDisp Script to create a Transformation with Input Data
"""

import json
from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1],
    'Usage:',
    '  %s transName' % Script.scriptName,
    'Arguments:',
    '  transName: name of the transformation',
    '\ne.g: %s evndisp-gamma-N' % Script.scriptName,
]))

Script.parseCommandLine()

import DIRAC
from CTADIRAC.TransformationSystem.Client.TransformationClient import TransformationClient
from CTADIRAC.Interfaces.API.EvnDisp3RefJob import EvnDisp3RefJob
from DIRAC.Interfaces.API.Dirac import Dirac


def submitTS(job, transName, mqJson):
    """ Create a transformation executing the job workflow  """
    DIRAC.gLogger.notice('submitTS')

    tc = TransformationClient()

    res = tc.addTransformation(transName,
                               'EvnDisp3 example',
#!/usr/bin/env python

import json

import DIRAC
from DIRAC import S_OK, S_ERROR

from DIRAC.Core.Base import Script

Script.setUsageMessage(
    """
Delete task and all jobs in the task

Usage:
   %s [option] ... [TaskID] ...
"""
    % Script.scriptName
)

Script.parseCommandLine(ignoreErrors=False)
options = Script.getUnprocessedSwitches()
args = Script.getPositionalArgs()

from BESDIRAC.WorkloadManagementSystem.Client.TaskClient import TaskClient

taskClient = TaskClient()


def deleteTask(taskID):
    result = taskClient.deleteTask(taskID)
    if not result["OK"]:
예제 #37
0
  if arg not in userNames:
    userNames.append(arg)


def addProperty(arg):
  global groupProperties
  if not arg:
    Script.showHelp()
    DIRAC.exit(-1)
  if arg not in groupProperties:
    groupProperties.append(arg)


Script.setUsageMessage('\n'.join(['Add or Modify a Group info in DIRAC',
                                  '\nUsage:\n',
                                  '  %s [option|cfgfile] ... Property=<Value> ...' % Script.scriptName,
                                  '\nArguments:\n',
                                  '  Property=<Value>: Other properties to be added to the User like (VOMSRole=XXXX)',
                                  ]))

Script.registerSwitch('G:', 'GroupName:', 'Name of the Group (Mandatory)', setGroupName)
Script.registerSwitch(
    'U:',
    'UserName:'******'Short Name of user to be added to the Group (Allow Multiple instances or None)',
    addUserName)
Script.registerSwitch(
    'P:',
    'Property:',
    'Property to be added to the Group (Allow Multiple instances or None)',
    addProperty)
예제 #38
0
#!/usr/bin/env python
"""
  Restart DIRAC component using runsvctrl utility
"""
from __future__ import print_function
__RCSID__ = "$Id$"
#
from DIRAC.Core.Base import Script
Script.disableCS()
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... [System [Service|Agent]]' % Script.scriptName,
    'Arguments:',
    '  System:        Name of the system for the component (default *: all)',
    '  Service|Agent: Name of the particular component (default *: all)'
]))
Script.parseCommandLine()
args = Script.getPositionalArgs()
if len(args) > 2:
    Script.showHelp()
    exit(-1)

system = '*'
component = '*'
if args:
    system = args[0]
if system != '*':
    if len(args) > 1:
        component = args[1]
#
from DIRAC.FrameworkSystem.Client.ComponentInstaller import gComponentInstaller
예제 #39
0
#!/usr/bin/env python
""" update local cfg
"""

from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgFile] ... DB ...' % Script.scriptName
]))

Script.parseCommandLine()

args = Script.getPositionalArgs()
setupName = args[0]

import os

# Where to store outputs
if not os.path.isdir('%s/sandboxes' % setupName):
    os.makedirs('%s/sandboxes' % setupName)

# now updating the CS

from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI

csAPI = CSAPI()

csAPI.setOption(
    'Systems/WorkloadManagement/Production/Services/SandboxStore/BasePath',
    '%s/sandboxes' % setupName)
예제 #40
0
#!/usr/bin/env python
"""
  Create a Transformation for MC Simulation Production Jobs 
"""
import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... [corsikaTemplate] ...' % Script.scriptName,
    'Arguments:',
    '  corsikaTemplate:    Corsika config file as in /vo.cta.in2p3.fr/MC/PROD2/xxx/prod2_cfg.tar.gz',
    '  reprocessing configuration: STD/NSBX3/4MSST/SCSST/ASTRI/NORTH/3INROW'
]))

Script.parseCommandLine()


def MCProdTSExample(args=None):

    from DIRAC.TransformationSystem.Client.Transformation import Transformation
    from DIRAC.Core.Workflow.Parameter import Parameter
    from DIRAC.Interfaces.API.Dirac import Dirac
    from CTADIRAC.Interfaces.API.ProdTSJob import ProdTSJob

    if (len(args) != 2):
        Script.gLogger.notice('Wrong number of arguments')
        Script.showHelp()

    cfgfile = args[0]
    simtelArrayConfig = args[1]
예제 #41
0
#!/usr/bin/env python
"""
  Submit a Software List Job
"""

from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... [version]' % Script.scriptName, 'Arguments:',
    '  package: corsika_simhessarray/evndisplay/HESS/ctools',
    '  version: prod-2_21122012/prod-2_08032013/prod-2_06052013/prod-2_06052013_sc3/prod2_130708/prod2_130718/v0.1',
    '  site: Site Destination'
]))

Script.parseCommandLine()


def SoftList(args=None):

    from DIRAC.Interfaces.API.Dirac import Dirac
    from DIRAC.Interfaces.API.Job import Job

    if (len(args) != 3):
        Script.showHelp()

    package = args[0]
    version = args[1]
    site = args[2]

    j = Job()
matching a given pattern / query.
    
         cta-prod3-get-matching-data.py JB, LA 2016
"""

# generic imports
import os

# DIRAC import Script
import DIRAC
from DIRAC.Core.Base import Script
 
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s funcName' % Script.scriptName,
                                     'Arguments:',
                                     '  stepName: sub5, sub2sub5, HB9SCT',
                                     '\ne.g: %s sub5' % Script.scriptName
                                     ] ) )

Script.parseCommandLine()

# Other DIRAC imports
from DIRAC.Interfaces.API.Dirac import Dirac
from DIRAC.DataManagementSystem.Client.DataManager  import DataManager

def downloadFile(lfn):
    """ Download a file using DMS
    Keyword arguments:
    lfn -- a logical file name
    """
예제 #43
0
    option, value = optVal.split('=')
    specialOptions[option] = value
    return S_OK()


Script.registerSwitch("w", "overwrite",
                      "Overwrite the configuration in the global CS",
                      setOverwrite)
Script.registerSwitch("m:", "module=",
                      "Python module name for the executor code", setModule)
Script.registerSwitch("p:", "parameter=", "Special executor option ",
                      setSpecialOption)
Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1], 'Usage:',
    '  %s [option|cfgfile] ... System Service|System/Service' %
    Script.scriptName, 'Arguments:',
    '  System:  Name of the DIRAC system (ie: WorkloadManagement)',
    '  Service: Name of the DIRAC service (ie: Matcher)'
]))

Script.parseCommandLine()
args = Script.getPositionalArgs()

if len(args) == 1:
    args = args[0].split('/')

if len(args) != 2:
    Script.showHelp()
    exit(-1)
#
system = args[0]
예제 #44
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
# File :    dirac-admin-get-site-mask
# Author :  Stuart Paterson
########################################################################
__RCSID__ = "$Id$"

from DIRAC.Core.Base import Script

Script.setUsageMessage("""
Get the list of sites enabled in the mask for job submission

Usage:
   %s [options]
""" % Script.scriptName)

Script.parseCommandLine(ignoreErrors=True)

from DIRAC import exit as DIRACExit, gLogger
from DIRAC.Interfaces.API.DiracAdmin import DiracAdmin

diracAdmin = DiracAdmin()

gLogger.setLevel('ALWAYS')

result = diracAdmin.getSiteMask(printOutput=True)
if result['OK']:
    DIRACExit(0)
else:
    print result['Message']
예제 #45
0
########################################################################
"""
  Report Normalized CPU length of queue

  This script was used by the dirac-pilot script to set the CPUTime limit for the matching but now this is no more the case
"""
from __future__ import print_function
__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script
from DIRAC.WorkloadManagementSystem.Client.CPUNormalization import queueNormalizedCPU

Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s [option|cfgfile] ... Queue ...' % Script.scriptName,
                                  'Arguments:',
                                  '  Queue:     GlueCEUniqueID of the Queue (ie, juk.nikhef.nl:8443/cream-pbs-lhcb)']))
Script.parseCommandLine(ignoreErrors=True)
args = Script.getPositionalArgs()

if len(args) < 1:
  Script.showHelp()

exitCode = 0

for ceUniqueID in args:

  normCPU = queueNormalizedCPU(ceUniqueID)

  if not normCPU['OK']:
예제 #46
0
#! /usr/bin/env python
########################################################################
# $HeadURL: $
########################################################################
__RCSID__ = "$Id:  $"

from DIRAC import exit as DIRACExit
from DIRAC.Core.Base import Script

Script.setUsageMessage("""
Clean the given directory or a list of directories by removing it and all the
contained files and subdirectories from the physical storage and from the
file catalogs.

Usage:
   %s <lfn | fileContainingLfns> <SE> <status>
""" % Script.scriptName)

Script.parseCommandLine()
import sys, os

from DIRAC.Core.Utilities.List import sortList, randomize

if len(sys.argv) < 2:
    Script.showHelp()
    DIRACExit(-1)
else:
    inputFileName = sys.argv[1]

if os.path.exists(inputFileName):
    inputFile = open(inputFileName, 'r')
예제 #47
0
                      'Switches off additional check before submission')
Script.registerSwitch(
    'g:', 'group=', 'Name of the production group (default set by metadata)')
Script.registerSwitch('p:', 'prodid=', 'Production ID of input')
Script.registerSwitch('t:', 'time=',
                      'CPU time limit per job in seconds (default 300000)')
Script.registerSwitch('v:', 'version=', 'SLIC version to use (default v2r8p4)')
Script.registerSwitch('l:', 'lcsim=',
                      'LCSIM version to use (default 1.15-SNAPHOT)')
Script.registerSwitch('P:', 'pandora=',
                      'SlicPandora version to use (default CDR0)')

Script.registerSwitch('w:', 'workflow=',
                      'Name of the workflow (default set by metadata)')

Script.setUsageMessage(
    sys.argv[0] + ' -m <detectorModel> -p <prodID> (<additional options>)')

Script.parseCommandLine()
switches = Script.getUnprocessedSwitches()

detectorName = None
prodID = None
eventType = None
dataType = ''
energy = ''
prodGroup = None
cpuLimit = 300000
workflowName = None
workflowDescription = None
checkMeta = True
예제 #48
0
# -*- coding: utf-8 -*-

import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage("""
Create a data transfer request.

Usage:
  %s <dataset name> <src SE> <dst SE>
""" % Script.scriptName)

Script.parseCommandLine(ignoreErrors=True)

args = Script.getPositionalArgs()
if (len(args) != 3):
    gLogger.error("Please support dataset name, src SE, dst SE.")
    DIRAC.exit(-1)

from DIRAC.Core.DISET.RPCClient import RPCClient

transferRequest = RPCClient("Transfer/TransferRequest")

dataset = args[0]
ep_from = args[1]
ep_to = args[2]

print transferRequest.create(dataset, ep_from, ep_to)
#!/usr/bin/env python

import json

import DIRAC
from DIRAC import S_OK, S_ERROR

from DIRAC.Core.Base import Script

Script.setUsageMessage( """
Get task progress of events

Usage:
   %s TaskID1 TaskID2 ...
""" % Script.scriptName )

Script.parseCommandLine( ignoreErrors = False )
options = Script.getUnprocessedSwitches()
args = Script.getPositionalArgs()

from IHEPDIRAC.WorkloadManagementSystem.Client.TaskClient   import TaskClient
taskClient = TaskClient()

from DIRAC.Core.DISET.RPCClient           import RPCClient
jobMonitor = RPCClient('WorkloadManagement/JobMonitoring')

def getTaskEventProgress(taskID):
    progress = {}

    result = taskClient.getTaskJobs(taskID)
    if not result['OK']:
예제 #50
0
#!/usr/bin/env python
""" Prod3 MC Script to install software
"""

# generic imports
import os

# DIRAC imports
import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([
    __doc__.split('\n')[1],
    'Usage:',
    '  %s package version (arch)' % Script.scriptName,
    'Arguments:',
    '  package: corsika_simhessarray',
    '  version: 2015-07-13',
    '\ne.g: %s corsika_simhessarray 2015-06-02' % Script.scriptName,
]))

Script.parseCommandLine()

# Specific DIRAC imports
from CTADIRAC.Core.Utilities.Prod3SoftwareManager import Prod3SoftwareManager


def removeSoftwarePackage(args):
    """ remove a given software package
        to be used in main
    Keyword arguments:
 def registerSwitches(self):
   Script.registerSwitch( 'O', 'Outputdata', 'retrieve also the outputdata', self.setOuputData)
   Script.registerSwitch( 'r:', 'Repository=', 'repository file to use', self.setRepo)
   Script.setUsageMessage('\n'.join( [ __doc__.split( '\n' )[1],
                                       '\nUsage:',
                                       '  %s [option|cfgfile] ...\n' % Script.scriptName ] )  )
예제 #52
0
########################################################################
""" Ban one or more Storage Elements for usage
"""
__RCSID__ = "$Id$"
import DIRAC
from DIRAC.Core.Base                                   import Script

read = True
write = True
check = True
site = ''
mute = False

Script.setUsageMessage( """
Ban one or more Storage Elements for usage

Usage:
   %s SE1 [SE2 ...]
""" % Script.scriptName )

Script.registerSwitch( "r" , "BanRead" , "     Ban only reading from the storage element" )
Script.registerSwitch( "w" , "BanWrite", "     Ban writing to the storage element" )
Script.registerSwitch( "k" , "BanCheck", "     Ban check access to the storage element" )
Script.registerSwitch( "m" , "Mute"    , "     Do not send email" )
Script.registerSwitch( "S:", "Site="   , "     Ban all SEs associate to site (note that if writing is allowed, check is always allowed)" )
Script.parseCommandLine( ignoreErrors = True )

ses = Script.getPositionalArgs()
for switch in Script.getUnprocessedSwitches():
  if switch[0].lower() == "r" or switch[0].lower() == "banread":
    write = False
    check = False
#!/usr/bin/env python
########################################################################
# $HeadURL$
########################################################################
__RCSID__   = "$Id$"

from DIRAC.Core.Base import Script 

Script.setUsageMessage("""
Get metadata for the given file specified by its Logical File Name or for a list of files
contained in the specifed file

Usage:
   %s <lfn | fileContainingLfns> [Catalog]
""" % Script.scriptName)

Script.parseCommandLine()

from DIRAC.Core.Utilities.List                          import sortList
from DIRAC.DataManagementSystem.Client.ReplicaManager   import ReplicaManager
import os,sys

if not len(sys.argv) >= 2:
  Script.showHelp()
  DIRAC.exit( -1 )
else:
  inputFileName = sys.argv[1]
  catalogs = []
  if len(sys.argv) == 3:
    catalogs = [sys.argv[2]]  
예제 #54
0
#!/usr/bin/env python

"""
  Delete a given production
"""

__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage('\n'.join([__doc__.split('\n')[1],
                                  'Usage:',
                                  '  %s prodID' % Script.scriptName,
                                  'Arguments:',
                                  '  prodID: Production ID'
                                  ]))


Script.parseCommandLine()

from DIRAC.ProductionSystem.Client.ProductionClient import ProductionClient

args = Script.getPositionalArgs()
if (len(args) != 1):
  Script.showHelp()

# get arguments
prodID = args[0]

prodClient = ProductionClient()
 def registerSwitches(self):
   Script.registerSwitch("x", "enable", "perform delete operations on file catalog", self.setEnabled)
   Script.setUsageMessage("""%s <transformationID> -x""" % Script.scriptName)
예제 #56
0
    There are no options.

  Examples:
    dirac-sys-sendmail "From: [email protected]\\nTo: [email protected]\\nSubject: Test\\n\\nMessage body"
    echo "From: [email protected]\\nSubject: Test\\n\\nMessage body" | dirac-sys-sendmail [email protected]
"""

__RCSID__ = "$Id$"

import socket , sys , os

from DIRAC                                              import gLogger, exit as DIRACexit
from DIRAC.Core.Base                                    import Script
from DIRAC.FrameworkSystem.Client.NotificationClient    import NotificationClient

Script.setUsageMessage( ''.join( __doc__ ) )

Script.parseCommandLine( ignoreErrors = True )
args = Script.getPositionalArgs()

arg = "".join( args )

if not len( arg ) > 0:
  gLogger.error( "Missing argument" )
  DIRACexit( 2 )

try:
  head , body = arg.split( "\\n\\n" )
except Exception , x:
  head = "To: %s" % arg
  body = sys.stdin.read()
예제 #57
0
########################################################################
# $HeadURL$
########################################################################
__RCSID__ = "$Id$"

import sys, os
import DIRAC
from DIRAC import gLogger
from DIRAC.Core.Base import Script

unit = 'GB'
Script.registerSwitch( "u:", "Unit=", "   Unit to use [default %s] (MB,GB,TB,PB)" % unit )

Script.setUsageMessage( """
Get the size of the given file or a list of files

Usage:
   %s <lfn | fileContainingLfns> <SE> <status>
""" % Script.scriptName )

Script.parseCommandLine( ignoreErrors = False )
for switch in Script.getUnprocessedSwitches():
  if switch[0].lower() == "u" or switch[0].lower() == "unit":
    unit = switch[1]
scaleDict = { 'MB' : 1000 * 1000.0,
              'GB' : 1000 * 1000 * 1000.0,
              'TB' : 1000 * 1000 * 1000 * 1000.0,
              'PB' : 1000 * 1000 * 1000 * 1000 * 1000.0}
if not unit in scaleDict.keys():
  gLogger.error( "Unit must be one of MB,GB,TB,PB" )
  DIRAC.exit( 2 )
scaleFactor = scaleDict[unit]
예제 #58
0
#!/usr/bin/env python

__RCSID__ = "$Id$"

import DIRAC
from DIRAC.Core.Base import Script

Script.setUsageMessage( """
Get PROD3 statistics for a given dataset
if no dataset is specified it gives the list of available datasets
Usage:
   %s <dataset>

""" % Script.scriptName )

Script.parseCommandLine( ignoreErrors = True )

from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient
from DIRAC.Core.Utilities.PrettyPrint import printTable

argss = Script.getPositionalArgs()

fc = FileCatalogClient()

datasetName = '*'
if len( argss ) > 0:
  datasetName = argss[0]

result = fc.getDatasets( datasetName )
if not result['OK']:
  print "ERROR: failed to get datasets"
예제 #59
0
#!/usr/bin/env python
########################################################################
# $HeadURL$
########################################################################
__RCSID__ = "$Id$"
from DIRAC.Core.Base import Script

Script.setUsageMessage( """
Remove the given file replica or a list of file replicas from the File Catalog 
and from the storage.

Usage:
   %s <LFN | fileContainingLFNs> SE [SE]
""" % Script.scriptName )

Script.parseCommandLine()

from DIRAC.Core.Utilities.List                        import sortList, breakListIntoChunks
from DIRAC.DataManagementSystem.Client.ReplicaManager import ReplicaManager
rm = ReplicaManager()
import os, sys

if len( sys.argv ) < 3:
  Script.showHelp()
  DIRAC.exit( -1 )
else:
  inputFileName = sys.argv[1]
  storageElementNames = sys.argv[2:]

if os.path.exists( inputFileName ):
  inputFile = open( inputFileName, 'r' )
예제 #60
0
#!/usr/bin/env python
"""
  Submit an Example HapJob
"""
from DIRAC.Core.Base import Script
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [option|cfgfile] ... [Site] ...' % Script.scriptName,
                                     'Arguments:',
                                     '  Site:     Requested Site' ] ) )
Script.parseCommandLine()

import os

def HapConverterExample( destination = None ) :
  from CTADIRAC.Interfaces.API.HapConverterJob import HapConverterJob
  from DIRAC.Interfaces.API.Dirac import Dirac

### general options ###############
  HapVersion = 'v0.18'

  infileLFNList = [
  'LFN:/vo.cta.in2p3.fr/Simulation/sim_telarray/Prod1S_PS/2000/gamma/20/90/spectrum_-2.0/0.003_300/pointlike/cta-prod1/0.0deg/Data/run283xxx/gamma_20deg_90deg_run283000___cta-prod1_desert.simhess.gz',
  'LFN:/vo.cta.in2p3.fr/Simulation/sim_telarray/Prod1S_PS/2000/gamma/20/90/spectrum_-2.0/0.003_300/pointlike/cta-prod1/0.0deg/Data/run283xxx/gamma_20deg_90deg_run283001___cta-prod1_desert.simhess.gz']

  for infileLFN in infileLFNList:
    infile = os.path.basename(infileLFN)
#### build the output file name for rawdata #############################
    PartType = infile.split( '_' )[0]
    RunNum = infile.split( 'run' )[1].split('___cta-prod1_desert.simhess.gz')[0]
    raw_fileout = 'raw_' + PartType + '_run' + RunNum + '.root'