コード例 #1
0
    def _fileFeatures(filePath):
        """ From a filepath, construct a dictionary of file features. """
        # pylint: disable=W0702
        log_debug(3, filePath)
        if not filePath:
            raise rhnFault(
                17,
                "While looking for file: `%s'" % os.path.basename(filePath))
        try:
            s = os.stat(filePath)
        except:
            s = None
        if not s:
            l = 0
            lastModified = 0
        else:
            l = s[stat.ST_SIZE]
            lastModified = s[stat.ST_MTIME]
        del s

        # Build the result hash
        result = {}
        result['name'] = os.path.basename(filePath)
        result['length'] = l
        result['path'] = filePath
        if lastModified:
            result['lastModified'] = rfc822time(lastModified)
        else:
            result['lastModified'] = None
        return result
コード例 #2
0
    def _fileFeatures(filePath):
        """ From a filepath, construct a dictionary of file features. """
        # pylint: disable=W0702
        log_debug(3, filePath)
        if not filePath:
            raise rhnFault(17, "While looking for file: `%s'"
                               % os.path.basename(filePath))
        try:
            s = os.stat(filePath)
        except:
            s = None
        if not s:
            l = 0
            lastModified = 0
        else:
            l = s[stat.ST_SIZE]
            lastModified = s[stat.ST_MTIME]
        del s

        # Build the result hash
        result = {}
        result['name'] = os.path.basename(filePath)
        result['length'] = l
        result['path'] = filePath
        if lastModified:
            result['lastModified'] = rfc822time(lastModified)
        else:
            result['lastModified'] = None
        return result
コード例 #3
0
ファイル: rhnRepository.py プロジェクト: bjmingyang/spacewalk
 def _set_last_modified(self, last_modified, extra_headers={}):
     log_debug(4, last_modified)
     if not last_modified:
         return None
     # Set a field with the name of the header
     transport = rhnFlags.get('outputTransportOptions')
     if last_modified:
         # Put the last-modified info too
         if type(last_modified) in (types.IntType, types.FloatType):
             last_modified = rfc822time(last_modified)
         transport['Last-Modified'] = last_modified
     for k, v in extra_headers.items():
         transport[str(k)] = str(v)
     return transport
コード例 #4
0
 def _set_last_modified(last_modified, extra_headers=None):
     log_debug(4, last_modified)
     if not last_modified:
         return None
     # Set a field with the name of the header
     transport = rhnFlags.get('outputTransportOptions')
     if last_modified:
         # Put the last-modified info too
         if type(last_modified) in (types.IntType, types.FloatType):
             last_modified = rfc822time(last_modified)
         transport['Last-Modified'] = last_modified
     if extra_headers:
         for k, v in extra_headers.items():
             transport[str(k)] = str(v)
     return transport