Пример #1
0
def checkInternalServices(errMsg='Internal services disabled. Job registry is read-only.'):
    """
    Check the state of internal services and return a ReadOnlyObjectError exception
    in case the state is disabled.    
    """

    global servicesEnabled
    from Ganga.GPIDev.Base import ReadOnlyObjectError

    if not servicesEnabled:
        raise ReadOnlyObjectError(errMsg)
Пример #2
0
    def extend(self, files, unique=False):
        '''Extend the dataset. If unique, then only add files which are not
        already in the dataset.'''
        from Ganga.GPIDev.Base import ReadOnlyObjectError

        if self._parent is not None and self._parent._readonly():
            raise ReadOnlyObjectError(
                'object Job#%s  is read-only and attribute "%s/inputdata" cannot be modified now'
                % (self._parent.id, getName(self)))

        _external_files = []

        if type(files) is str or isType(files, IGangaFile):
            _external_files = [files]
        elif type(files) in [list, tuple]:
            _external_files = files
        elif isType(files, LHCbDataset):
            _external_files = files.files
        else:
            if not hasattr(files, "__getitem__") or not hasattr(
                    files, '__iter__'):
                _external_files = [files]

        # just in case they extend w/ self
        _to_remove = []
        for this_file in _external_files:
            if hasattr(this_file, 'subfiles'):
                if len(this_file.subfiles) > 0:
                    _external_files = makeGangaListByRef(this_file.subfiles)
                    _to_remove.append(this_file)
            if type(this_file) is str:
                _external_files.append(
                    string_datafile_shortcut_lhcb(this_file, None))
                _to_remove.append(this_file)

        for _this_file in _to_remove:
            _external_files.pop(_external_files.index(_this_file))

        for this_f in _external_files:
            _file = getDataFile(this_f)
            if _file is None:
                _file = this_f
            myName = _file.namePattern
            from GangaDirac.Lib.Files.DiracFile import DiracFile
            if isType(_file, DiracFile):
                myName = _file.lfn
            if unique and myName in self.getFileNames():
                continue
            self.files.append(stripProxy(_file))
Пример #3
0
 def extend(self, files, unique=False):
     '''Extend the dataset. If unique, then only add files which are not
     already in the dataset.'''
     from Ganga.GPIDev.Base import ReadOnlyObjectError
     if not hasattr(files, "__getitem__"):
         raise GangaException('Argument "files" must be a iterable.')
     if self._getParent() is not None and self._getParent()._readonly():
         raise ReadOnlyObjectError(
             'object Job#%s  is read-only and attribute "%s/inputdata" cannot be modified now'
             % (self._getParent().id, getName(self)))
     names = self.getFileNames()
     files = [f for f in files]  # just in case they extend w/ self
     for f in files:
         if unique and f.name in names:
             continue
         self.files.append(f)