Beispiel #1
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
Beispiel #2
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
Beispiel #3
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
Beispiel #4
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
Beispiel #5
0
    if catalog.isDir( lfn ):
      # we can accept one ore more local files
      for lp in local_paths:
        pairs.append( (lp, os.path.join( lfn, os.path.basename( lp )) ))
    else:
      if len( local_paths ) > 1:
        print "Error: Destination LFN must be a directory when registering multiple local files"
        Script.showHelp( )
        DIRAC.exit( -1 )

      # lfn filename replace local filename
      pairs.append( (local_path, lfn ))

  # destination SE
  se = params.destinationSE
  if not se:
    retVal = session.getEnv( "default_se", "DIRAC-USER" )
    if not retVal[ "OK" ]:
      critical( retVal[ "Message" ] )
    se = retVal[ "Value" ]

  Script.enableCS( )

  from DIRAC.DataManagementSystem.Client.FileCatalogClientCLI import FileCatalogClientCLI
  fccli = FileCatalogClientCLI( catalog.catalog )

  for local_path, lfn in pairs:
    fccli.do_add( lfn + " " + local_path + " " + se )