Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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
Ejemplo n.º 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