Ejemplo n.º 1
0
 def add(self, input):
     from Ganga.Core.GangaRepository import getRegistry
     if not isType(input, list):
         input = [input]
     for item in input:
         if isType(item, str):
             if os.path.isfile(expandfilename(item)):
                 logger.info('Copying file %s to shared directory %s' %
                             (item, self.name))
                 shutil.copy2(expandfilename(item),
                              os.path.join(getSharedPath(), self.name))
                 shareref = GPIProxyObjectFactory(
                     getRegistry("prep").getShareRef())
                 shareref.increase(self.name)
                 shareref.decrease(self.name)
             else:
                 logger.error('File %s not found' % expandfilename(item))
         elif isType(item, File) and item.name is not '' and os.path.isfile(
                 expandfilename(item.name)):
             logger.info('Copying file object %s to shared directory %s' %
                         (item.name, self.name))
             shutil.copy2(expandfilename(item.name),
                          os.path.join(getSharedPath(), self.name))
             shareref = GPIProxyObjectFactory(
                 getRegistry("prep").getShareRef())
             shareref.increase(self.name)
             shareref.decrease(self.name)
         else:
             logger.error('File %s not found' % expandfilename(item.name))
Ejemplo n.º 2
0
    def __incrementShareRef(obj, attr_name):
        shared_dir = getattr(obj, attr_name)

        if hasattr(shared_dir, 'name'):

            from Ganga.Core.GangaRepository import getRegistry
            from Ganga.GPIDev.Base.Proxy import GPIProxyObjectFactory
            shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())

            logger.debug("Increasing shareref")
            shareref.increase(shared_dir.name)
Ejemplo n.º 3
0
 def __deepcopy__(self, memo = None):
     self._getReadAccess()
     c = super(GangaObject,self).__deepcopy__(memo)
     for name,item in self._schema.allItems():
         if not item['copyable']:
             setattr(c,name,self._schema.getDefaultValue(name))
         if item.isA(Schema.SharedItem):
             shared_dir=getattr(c,name)
             try:
                 from Ganga.Core.GangaRepository import getRegistry
                 shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())
                 logger.debug("Increasing shareref")
                 shareref.increase(shared_dir.name)
             except AttributeError:
                 pass
     return c
Ejemplo n.º 4
0
 def add(self, input):
     if not isType(input, list):
         input = [input] 
     for item in input:
         if isType(item, str):
             if os.path.isfile(expandfilename(item)):
                 logger.info('Copying file %s to shared directory %s'%(item, self.name))
                 shutil.copy2(expandfilename(item), os.path.join(shared_path,self.name))
                 shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())
                 shareref.increase(self.name)
                 shareref.decrease(self.name)
             else:
                 logger.error('File %s not found' % expandfilename(item))
         elif isType(item,File) and item.name is not '' and os.path.isfile(expandfilename(item.name)):
             logger.info('Copying file object %s to shared directory %s'%(item.name,self.name))
             shutil.copy2(expandfilename(item.name), os.path.join(shared_path,self.name))
             shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())
             shareref.increase(self.name)
             shareref.decrease(self.name)
         else:
             logger.error('File %s not found' % expandfilename(item.name))
Ejemplo n.º 5
0
    def __deepcopy__(self, memo=None):
        self = stripProxy(self)
        self._getReadAccess()
        c = super(GangaObject, self).__deepcopy__(memo)
        if self._schema is not None:
            for name, item in self._schema.allItems():
                if not item['copyable']:
                    setattr(c, name, self._schema.getDefaultValue(name))

                if item.isA(Schema.SharedItem):

                    shared_dir = getattr(c, name)

                    if hasattr(shared_dir, 'name'):

                        from Ganga.Core.GangaRepository import getRegistry
                        from Ganga.GPIDev.Base.Proxy import GPIProxyObjectFactory
                        shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())

                        logger.debug("Increasing shareref")
                        shareref.increase(shared_dir.name)
        return c
Ejemplo n.º 6
0
 def incrementShareCounter(self, shared_directory_name):
     logger.debug('Incrementing shared directory reference counter')
     shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())
     logger.debug('within incrementShareCounter, calling increase')
     shareref.increase(shared_directory_name)
Ejemplo n.º 7
0
 def incrementShareCounter(self, shared_directory_name):
     logger.debug('Incrementing shared directory reference counter')
     shareref = GPIProxyObjectFactory(getRegistry("prep").getShareRef())
     logger.debug('within incrementShareCounter, calling increase')
     shareref.increase(shared_directory_name)