コード例 #1
0
    def _setDirectoryParameter(self, path, pname, pvalue):
        """Set a numerical directory parameter

        :param mixed path: Directory path or paths as a string or directory ID as int,
                           list/tuple of ints or a string to select directory IDs
        :param str pname: parameter name
        :param int pvalue: parameter value
        """
        result = getIDSelectString(path)
        if not result["OK"] and isinstance(path, six.string_types):
            result = self.__getDirID(path)
            if not result["OK"]:
                return result
            dirID = result["Value"]
            result = getIDSelectString(dirID)
            if not result["OK"]:
                return result

        dirIDString = result["Value"]
        req = "UPDATE FC_DirectoryInfo SET %s=%d, " "ModificationDate=UTC_TIMESTAMP() WHERE DirID IN ( %s )" % (
            pname,
            pvalue,
            dirIDString,
        )
        result = self.db._update(req)
        return result
コード例 #2
0
ファイル: FileManager.py プロジェクト: pmusset/DIRAC
  def _setFileParameter(self, fileID, paramName, paramValue, connection=False):
    connection = self._getConnection(connection)

    result = getIDSelectString(fileID)
    if not result['OK']:
      return result
    fileIDString = result['Value']

    if paramName in ['UID', 'GID', 'Status', 'Size']:
      # Treat primary file attributes specially
      # Different statement for the fileIDString with SELECT is for performance optimization
      # since in this case the MySQL engine manages to use index on FileID.
      if 'select' in fileIDString.lower():
        tmpreq = "UPDATE FC_Files as FF1, ( %s ) as FF2 %%s WHERE FF1.FileID=FF2.FileID" % fileIDString
      else:
        tmpreq = "UPDATE FC_Files %%s WHERE FileID IN (%s)" % fileIDString
      req = tmpreq % "SET %s='%s'" % (paramName, paramValue)
      result = self.db._update(req, connection)
      if not result['OK']:
        return result
      if 'select' in fileIDString.lower():
        req = "UPDATE FC_FileInfo as FF1, ( %s ) as FF2" % fileIDString
        req += " SET ModificationDate=UTC_TIMESTAMP() WHERE FF1.FileID=FF2.FileID"
      else:
        req = "UPDATE FC_FileInfo SET ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % fileIDString
    else:
      # Different statement for the fileIDString with SELECT is for performance optimization
      # since in this case the MySQL engine manages to use index on FileID.
      if 'select' in fileIDString.lower():
        req = "UPDATE FC_FileInfo as FF1, ( %s ) as FF2 SET %s='%s', " % (fileIDString, paramName, paramValue)
        req += "ModificationDate=UTC_TIMESTAMP() WHERE FF1.FileID=FF2.FileID"
      else:
        req = "UPDATE FC_FileInfo SET %s='%s', ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % \
              (paramName, paramValue, fileIDString)
    return self.db._update(req, connection)
コード例 #3
0
    def _setFileParameter(self,
                          fileID,
                          paramName,
                          paramValue,
                          connection=False):
        connection = self._getConnection(connection)

        result = getIDSelectString(fileID)
        if not result['OK']:
            return result
        fileIDString = result['Value']

        if paramName in ['UID', 'GID', 'Status', 'Size']:
            # Treat primary file attributes specially
            if 'select' in fileIDString.lower():
                tmpreq = "UPDATE FC_Files as FF1, ( %s ) as FF2 %%s WHERE FF1.FileID=FF2.FileID" % fileIDString
            else:
                tmpreq = "UPDATE FC_Files %%s WHERE FileID IN (%s)" % fileIDString
            req = tmpreq % "SET %s='%s'" % (paramName, paramValue)
            result = self.db._update(req, connection)
            if not result['OK']:
                return result
            req = "UPDATE FC_FileInfo SET ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % fileIDString
        else:
            req = "UPDATE FC_FileInfo SET %s='%s', ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % (
                paramName, paramValue, fileIDString)
        return self.db._update(req, connection)
コード例 #4
0
ファイル: FileManager.py プロジェクト: DIRACGrid/DIRAC
  def _setFileParameter( self, fileID, paramName, paramValue, connection = False ):
    connection = self._getConnection(connection)

    result = getIDSelectString( fileID )
    if not result['OK']:
      return result
    fileIDString = result['Value']

    if paramName in ['UID','GID','Status','Size']:
      # Treat primary file attributes specially
      # Different statement for the fileIDString with SELECT is for performance optimization
      # since in this case the MySQL engine manages to use index on FileID.
      if 'select' in fileIDString.lower():
        tmpreq = "UPDATE FC_Files as FF1, ( %s ) as FF2 %%s WHERE FF1.FileID=FF2.FileID" % fileIDString
      else:
        tmpreq = "UPDATE FC_Files %%s WHERE FileID IN (%s)" % fileIDString
      req = tmpreq % "SET %s='%s'" % ( paramName, paramValue )
      result = self.db._update(req,connection)
      if not result['OK']:
        return result
      if 'select' in fileIDString.lower():
        req = "UPDATE FC_FileInfo as FF1, ( %s ) as FF2 SET ModificationDate=UTC_TIMESTAMP() WHERE FF1.FileID=FF2.FileID" % fileIDString
      else:
        req = "UPDATE FC_FileInfo SET ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % fileIDString
    else:
      # Different statement for the fileIDString with SELECT is for performance optimization
      # since in this case the MySQL engine manages to use index on FileID.
      if 'select' in fileIDString.lower():
        req = "UPDATE FC_FileInfo as FF1, ( %s ) as FF2 SET %s='%s', ModificationDate=UTC_TIMESTAMP() WHERE FF1.FileID=FF2.FileID" % \
              ( fileIDString, paramName, paramValue )
      else:
        req = "UPDATE FC_FileInfo SET %s='%s', ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % \
              ( paramName, paramValue, fileIDString )
    return self.db._update( req, connection )
コード例 #5
0
ファイル: FileManager.py プロジェクト: DIRACGrid/DIRAC
    def _setFileParameter(self, fileID, paramName, paramValue, connection=False):
        connection = self._getConnection(connection)

        result = getIDSelectString(fileID)
        if not result["OK"]:
            return result
        fileIDString = result["Value"]

        if paramName in ["UID", "GID", "Status", "Size"]:
            # Treat primary file attributes specially
            if "select" in fileIDString.lower():
                tmpreq = "UPDATE FC_Files as FF1, ( %s ) as FF2 %%s WHERE FF1.FileID=FF2.FileID" % fileIDString
            else:
                tmpreq = "UPDATE FC_Files %%s WHERE FileID IN (%s)" % fileIDString
            req = tmpreq % "SET %s='%s'" % (paramName, paramValue)
            result = self.db._update(req, connection)
            if not result["OK"]:
                return result
            req = "UPDATE FC_FileInfo SET ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % fileIDString
        else:
            req = "UPDATE FC_FileInfo SET %s='%s', ModificationDate=UTC_TIMESTAMP() WHERE FileID IN (%s)" % (
                paramName,
                paramValue,
                fileIDString,
            )
        return self.db._update(req, connection)
コード例 #6
0
  def _setDirectoryParameter( self, path, pname, pvalue ):
    """ Set a numerical directory parameter

        :param mixed path: Directory path or paths as a string or directory ID as int,
                           list/tuple of ints or a string to select directory IDs
        :param str pname: parameter name
        :param int pvalue: parameter value
    """
    result = getIDSelectString( path )
    if not result['OK'] and isinstance( path, basestring ):
      result = self.__getDirID( path )
      if not result['OK']:
        return result
      dirID = result['Value']
      result = getIDSelectString( dirID )
      if not result['OK']:
        return result

    dirIDString = result['Value']
    req = "UPDATE FC_DirectoryInfo SET %s=%d, " \
          "ModificationDate=UTC_TIMESTAMP() WHERE DirID IN ( %s )" % \
          ( pname, pvalue, dirIDString )
    result = self.db._update( req )
    return result
コード例 #7
0
ファイル: FileManager.py プロジェクト: DIRACGrid/DIRAC
    def _getDirectoryFileIDs(self, dirID, requestString=False):
        """Get a list of IDs for all the files stored in given directories or their
            subdirectories
        :param mixt dirID: single directory ID or a list of directory IDs
        :param boolean requestString: if True return result as a SQL SELECT string
        :return: list of file IDs or SELECT string
        """

        result = getIDSelectString(dirID)
        if not result["OK"]:
            return result
        dirListString = result["Value"]

        if requestString:
            req = "SELECT FileID FROM FC_Files WHERE DirID IN ( %s )" % dirListString
            return S_OK(req)

        req = "SELECT FileID,DirID,FileName FROM FC_Files WHERE DirID IN ( %s )" % dirListString
        result = self.db._query(req)
        return result
コード例 #8
0
ファイル: FileManager.py プロジェクト: DIRACGrid/DIRAC
  def _getDirectoryFileIDs( self, dirID, requestString = False ):
    """ Get a list of IDs for all the files stored in given directories or their
        subdirectories
    :param mixt dirID: single directory ID or a list of directory IDs
    :param boolean requestString: if True return result as a SQL SELECT string
    :return: list of file IDs or SELECT string
    """

    result = getIDSelectString( dirID )
    if not result['OK']:
      return result
    dirListString = result['Value']

    if requestString:
      req = "SELECT FileID FROM FC_Files WHERE DirID IN ( %s )" % dirListString
      return S_OK( req )

    req = "SELECT FileID,DirID,FileName FROM FC_Files WHERE DirID IN ( %s )" % dirListString
    result = self.db._query( req )
    return result