コード例 #1
0
ファイル: DirectoryClosure.py プロジェクト: pmusset/DIRAC
    def _setDirectoryParameter(self, path, pname, pvalue, recursive=False):
        """ Set a numerical directory parameter


      Rem: the parent class has a more generic method, which is called
           in case we are given an unknown parameter

      :param path: path of the directory
      :param pname: name of the parameter to set
      :param pvalue: value of the parameter (an id or a value)

      :returns: S_OK(nb of row changed). It should always be 1 !
              S_ERROR if the directory does not exist
    """

        # The PS associated with a given parameter
        psNames = {
            'UID': 'ps_set_dir_uid',
            'GID': 'ps_set_dir_gid',
            'Status': 'ps_set_dir_status',
            'Mode': 'ps_set_dir_mode',
        }

        psName = psNames.get(pname, None)

        # If we have a recursive procedure and it is wanted, call it
        if recursive and pname in ['UID', 'GID', 'Mode'] and psName:
            psName += '_recursive'

        # If there is an associated procedure, we go for it
        if psName:
            result = self.db.executeStoredProcedureWithCursor(
                psName, (path, pvalue))

            if not result['OK']:
                return result

            errno, affected, errMsg = result['Value'][0]
            if errno:
                return S_ERROR(errMsg)

            if not affected:
                # Either there were no changes, or the directory does not exist
                exists = self.existsDir(path).get('Value', {}).get('Exists')
                if not exists:
                    return S_ERROR(errno.ENOENT,
                                   'Directory does not exist: %s' % path)
                affected = 1

            return S_OK(affected)

        # In case this is a 'new' parameter, we have a fallback solution, but we should add a specific ps for it
        else:
            return DirectoryTreeBase._setDirectoryParameter(
                self, path, pname, pvalue)
コード例 #2
0
 def __init__(self, database=None):
     DirectoryTreeBase.__init__(self, database)
     self.treeTable = "FC_DirectoryTree"
コード例 #3
0
# from DIRAC.DataManagementSystem.DB.FileCatalogComponents.DirectorySimpleTree import DirectorySimpleTree
# from DIRAC.DataManagementSystem.DB.FileCatalogComponents.DirectoryFlatTree import DirectoryFlatTree
# from DIRAC.DataManagementSystem.DB.FileCatalogComponents.DirectoryNodeTree import DirectoryNodeTree

from DIRAC.DataManagementSystem.DB.FileCatalogComponents.FileManager.FileManagerBase import FileManagerBase

dbMock = MagicMock()
ugManagerMock = MagicMock()
ugManagerMock.getUserAndGroupID.return_value = {"OK": True, "Value": ("l_uid", "l_gid")}
dbMock.ugManager = ugManagerMock


####################################################################################
# TreeBase

dtb = DirectoryTreeBase()
dtb.db = dbMock


def test_Base_makeDirectory():
    res = dtb.makeDirectory("/path", {})
    assert res["OK"] is False  # this will need to be implemented on a derived class


####################################################################################
# LevelTree

dlt = DirectoryLevelTree()
dlt.db = dbMock

コード例 #4
0
ファイル: DirectoryClosure.py プロジェクト: pmusset/DIRAC
 def __init__(self, database=None):
     DirectoryTreeBase.__init__(self, database)
     self.directoryTable = 'FC_DirectoryList'
     self.closureTable = 'FC_DirectoryClosure'