Exemple #1
0
 def unlink(self, path):
     print '*** unlink', path
     from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
     from COMDIRAC.Interfaces import DCatalog
     fcc = FileCatalogClientCLI(DCatalog().catalog)
     fcc.do_rm(path)
     return 0
Exemple #2
0
 def chmod(self, path, mode):
     print '*** chmod', path, oct(mode)
     from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
     from COMDIRAC.Interfaces import DCatalog
     FileCatalogClientCLI(DCatalog().catalog).do_chmod(
         str(oct(mode & 0777))[1:] + " " + path)
     #return -errno.ENOSYS
     return 0
Exemple #3
0
 def rmdir(self, path):
     print '*** rmdir', path
     from DIRAC.Resources.Catalog.FileCatalogClient import FileCatalogClient
     result = FileCatalogClient().listDirectory(path)
     flist = result['Value']['Successful'][path]['Files'].keys()
     if not flist:
         from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
         from COMDIRAC.Interfaces import DCatalog
         FileCatalogClientCLI(DCatalog().catalog).do_rmdir(path)
         return 0
     else:
         return -errno.ENOTEMPTY
Exemple #4
0
 def create(self, path, flags, mode):
     from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
     from COMDIRAC.Interfaces import DCatalog
     fcc = FileCatalogClientCLI(DCatalog().catalog)
     tmp = str(time.time()) + str(random.random())
     f = open(self.tmpdir + '/' + tmp, 'w+b')
     f.write("\0")
     f.close()
     fcc.do_add(path + " " + self.tmpdir + "/" + tmp + " " + self.SE)
     os.remove(self.tmpdir + '/' + tmp)
     self.file[path] = {
         "handler": os.tmpfile(),
         "modified": False
     }  #,"mode":os.stat(path)[stat.ST_MODE]}
     self.file[path]["handler"].write("\0")
     return 0
Exemple #5
0
    def release(self, path, flags):
        print '*** release', path, flags
        #if self.file[path]["mode"]&(stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH):
        #    return -errno.EACCES
        #print self.file[path]
        if self.file[path]["modified"]:
            self.file[path]["handler"].seek(0)
            off = 1 if self.file[path]["handler"].read(1) == '\0' else 0

            tmp = str(time.time()) + str(random.random())
            f = open(self.tmpdir + '/' + tmp, "w+b")
            self.file[path]["handler"].seek(off)
            f.write(self.file[path]["handler"].read())
            f.close()

            from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
            from COMDIRAC.Interfaces import DCatalog
            fcc = FileCatalogClientCLI(DCatalog().catalog)
            fcc.do_rm(path)
            fcc.do_add(path + " " + self.tmpdir + "/" + tmp + " " + self.SE)
            os.remove(self.tmpdir + '/' + tmp)
        self.file[path]["handler"].close()
        del self.file[path]
        return 0
Exemple #6
0
 def mkdir(self, path, mode):
     print '*** mkdir', path, oct(mode)
     from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
     from COMDIRAC.Interfaces import DCatalog
     FileCatalogClientCLI(DCatalog().catalog).do_mkdir(path)
     return 0
Exemple #7
0
                                       '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 ) ]

  if len( args ) > 1:
Exemple #8
0
                        )

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( )

catalog = DCatalog( )

if catalog.isDir( arg ):
  if( session.getCwd( ) != arg ):
    session.setCwd( arg )
    session.write( )
else:
  critical( "Error: \"%s\" not a valid directory" % arg )