Exemple #1
0
    )
)
Script.registerSwitch("p", "fromProxy", "build session from existing proxy", params.setFromProxy)
Script.registerSwitch("D", "destroy", "destroy session information", params.setDestroy)

Script.disableCS()

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

profile = None
if len(args):
    profile = args[0]

if params.destroy:
    session = DSession()
    os.unlink(session.configPath)
    DIRAC.exit(0)

session = None
if params.fromProxy:
    retVal = Script.enableCS()
    if not retVal["OK"]:
        critical(retVal["Message"])

    session = sessionFromProxy()
else:
    session = DSession(profile)

if not session:
    print "Error: Session couldn't be initialized"
Exemple #2
0
                                       'Usage:',
                                       '  %s [options] lfn...' % Script.scriptName,
                                       'Arguments:',
                                       ' lfn:          file entry in the FileCatalog',
                                       '', 'Examples',
                                      '  $ drepl ./some_lfn_file',
                                      '  $ drepl -D SOME-DESTINATION-SE-disk ./some_lfn_file',
                                       ] )
                          )
  Script.registerSwitch( "D:", "destination-se=", "Storage Element where to put replica (or a comma separated list)", params.setDestinationSE )
  Script.registerSwitch( "S:", "source-se=", "source Storage Element for replication", params.setSourceSE )

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

  session = DSession()
  catalog = DCatalog()

  if len( args ) < 1:
    print "Error: No argument provided\n%s:" % Script.scriptName
    Script.showHelp()
    DIRAC.exit( -1 )

  # default lfn: same file name as local_path
  lfns = pathFromArguments( session, args )

  # destination SE
  dsts = [ ]

  if params.destinationSE:
    dsts = params.destinationSE.split( "," )
Exemple #3
0
  import sys

  from DIRAC.Core.Base import Script

  Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       'Usage:',
                                       '  %s [[section.]option]...' % Script.scriptName,
                                       'Arguments:',
                                       '  section:     section (default: "session:environment")',
                                       '  option:      option name',] )
                          )

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

  session = DSession( )

  modified = False
  for arg in args:
    section = None
    option = None

    if "." in arg:
      section, option = arg.split( "." )
    else:
      option = arg

    if section:
      session.remove( section, option )
    else:
      session.unsetEnv( option )
Exemple #4
0
#!/usr/bin/env python

"""
print DCommands working directory
"""

import os

from COMDIRAC.Interfaces import critical

from COMDIRAC.Interfaces import DSession

if __name__ == "__main__":
  import sys
  from DIRAC.Core.Base import Script

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

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

  session = DSession( )

  ret = session.getCwd( )

  print ret
Exemple #5
0
                                       '  %s [options] local_path[... lfn]' % Script.scriptName,
                                       'Arguments:',
                                       ' local_path:   local file',
                                       ' lfn:          file or directory entry in the file catalog',
                                       '', 'Examples:',
                                       '  $ dput some_local_file ./some_lfn_file',
                                       '  $ dput local_file1 local_file2 ./some_lfn_dir/',
                                       ] )
                          )
  Script.registerSwitch( "D:", "destination-se=", "Storage Element where to put replica", params.setDestinationSE )


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

  session = DSession( )
  catalog = DCatalog( )

  if len( args ) < 1:
    print "Error: No argument provided\n%s:" % Script.scriptName
    Script.showHelp( )
    DIRAC.exit( 0 )

  # local file
  local_path = args[ 0 ]

  # default lfn: same file name as local_path
  lfn = pathFromArgument( session, os.path.basename( local_path ))

  pairs = [ ( local_path, lfn ) ]
Exemple #6
0
Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                     'Usage:',
                                     '  %s [Path]' % Script.scriptName,
                                     'Arguments:',
                                     '  Path:     path to new working directory (defaults to home directory)',
                                     '', 'Examples:',
                                     '  $ dcd /dirac/user',
                                     '  $ dcd',
                                     ] )
                        )

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

session = DSession( )

if len( args ) > 1:
  print "Error: too many arguments provided\n%s:" % Script.scriptName
  Script.showHelp( )
  DIRAC.exit( -1 )

if len( args ):
  arg = args[ 0 ]
  if not os.path.isabs( arg ):
    arg = os.path.normpath( os.path.join( session.getCwd( ), arg ))
else:
  arg = session.homeDir( )

Script.enableCS( )
Exemple #7
0
  import sys
  from DIRAC.Core.Base import Script

  Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       'Usage:',
                                       '  %s [[section.]option]' % Script.scriptName,
                                       'Arguments:',
                                       ' section:     display all options in section',
                                       '++ OR ++',
                                       ' section.option:     display section specific option',] )
                          )

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

  session = DSession( )

  if not args:
    retVal = session.listEnv( )
    if not retVal[ "OK" ]:
      print "Error:", retVal[ "Message" ]
      DIRAC.exit( -1 )
    for o, v in retVal[ "Value" ]:
      print o + "=" + v
    DIRAC.exit( 0 )

  arg = args[ 0 ]

  section = None
  option = None
Script.parseCommandLine()

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

import DIRAC.Core.Security.ProxyInfo as ProxyInfo

import DIRAC.FrameworkSystem.Client.ProxyGeneration as ProxyGeneration

from DIRAC.Core.Security import Locations, VOMS
from DIRAC.Core.Utilities.PrettyPrint import printTable

##################################
##################################
## Current pwd
session = DSession()
PWD = session.getCwd( )

## printer
pp = pprint.PrettyPrinter(indent=4)

## PROXY MANAGEMENT STUFF - before anything else
def _getProxyLocation():
  return Locations.getProxyLocation()

def _getProxyInfo( proxyPath = False ):
    if not proxyPath:
        proxyPath = _getProxyLocation()
    proxy_info = ProxyInfo.getProxyInfo( proxyPath, False )
    return proxy_info
Exemple #9
0
  from DIRAC.Core.Base import Script

  Script.setUsageMessage( '\n'.join( [ __doc__.split( '\n' )[1],
                                       'Usage:',
                                       '  %s [[section.]option=value]...' % Script.scriptName,
                                       'Arguments:',
                                       '  section:     section (defaults to "session:environment")',
                                       '  option:      option name',
                                       '  value:       value to be set',] )
                          )

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

  session = DSession( )

  modified = False
  for arg in args:
    section = None
    option = None

    arg, value = arg.split( "=" )
    if "." in arg:
      section, option = arg.split( "." )
    else:
      option = arg

    if section:
      session.set( section, option, value )
    else: