當前位置: 首頁>>代碼示例>>Python>>正文


Python stat.ST_MTIME屬性代碼示例

本文整理匯總了Python中stat.ST_MTIME屬性的典型用法代碼示例。如果您正苦於以下問題:Python stat.ST_MTIME屬性的具體用法?Python stat.ST_MTIME怎麽用?Python stat.ST_MTIME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在stat的用法示例。


在下文中一共展示了stat.ST_MTIME屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: open_local_file

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def open_local_file(self, req):
        host = req.get_host()
        file = req.get_selector()
        localfile = url2pathname(file)
        stats = os.stat(localfile)
        size = stats[stat.ST_SIZE]
        modified = rfc822.formatdate(stats[stat.ST_MTIME])
        mtype = mimetypes.guess_type(file)[0]
        stats = os.stat(localfile)
        headers = mimetools.Message(StringIO(
            'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
            (mtype or 'text/plain', size, modified)))
        if host:
            host, port = splitport(host)
        if not host or \
           (not port and socket.gethostbyname(host) in self.get_names()):
            return addinfourl(open(localfile, 'rb'),
                              headers, 'file:'+file)
        raise URLError('file not on local host') 
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:21,代碼來源:urllib2.py

示例2: _check

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def _check(self, uri, template):
        if template.filename is None:
            return template

        try:
            template_stat = os.stat(template.filename)
            if template.module._modified_time < template_stat[stat.ST_MTIME]:
                self._collection.pop(uri, None)
                return self._load(template.filename, uri)
            else:
                return template
        except OSError:
            self._collection.pop(uri, None)
            raise exceptions.TemplateLookupException(
                "Cant locate template for uri %r" % uri
            ) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:18,代碼來源:lookup.py

示例3: _check

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def _check(self, uri, template):
        if template.filename is None:
            return template

        try:
            template_stat = os.stat(template.filename)
            if template.module._modified_time < \
                    template_stat[stat.ST_MTIME]:
                self._collection.pop(uri, None)
                return self._load(template.filename, uri)
            else:
                return template
        except OSError:
            self._collection.pop(uri, None)
            raise exceptions.TemplateLookupException(
                "Cant locate template for uri %r" % uri) 
開發者ID:jpush,項目名稱:jbox,代碼行數:18,代碼來源:lookup.py

示例4: run

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def run(self):
        last_time = os.stat(self.filename)[stat.ST_MTIME]
        while 1:
            try:
                rc = win32event.WaitForSingleObject(self.handle, 
                                                    win32event.INFINITE)
                win32file.FindNextChangeNotification(self.handle)
            except win32event.error, details:
                # handle closed - thread should terminate.
                if details[0] != winerror.ERROR_INVALID_HANDLE:
                    raise
                break
            this_time = os.stat(self.filename)[stat.ST_MTIME]
            if this_time != last_time:
                print "Detected file change - flagging for reload."
                self.change_detected = True
                last_time = this_time 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:advanced.py

示例5: CheckLoaderModule

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def CheckLoaderModule(dll_name):
    suffix = ""
    if is_debug_build: suffix = "_d"
    template = os.path.join(this_dir,
                            "PyISAPI_loader" + suffix + ".dll")
    if not os.path.isfile(template):
        raise ConfigurationError(
              "Template loader '%s' does not exist" % (template,))
    # We can't do a simple "is newer" check, as the DLL is specific to the
    # Python version.  So we check the date-time and size are identical,
    # and skip the copy in that case.
    src_stat = os.stat(template)
    try:
        dest_stat = os.stat(dll_name)
    except os.error:
        same = 0
    else:
        same = src_stat[stat.ST_SIZE]==dest_stat[stat.ST_SIZE] and \
               src_stat[stat.ST_MTIME]==dest_stat[stat.ST_MTIME]
    if not same:
        log(2, "Updating %s->%s" % (template, dll_name))
        shutil.copyfile(template, dll_name)
        shutil.copystat(template, dll_name)
    else:
        log(2, "%s is up to date." % (dll_name,)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:install.py

示例6: newer

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def newer(source, target):
    """Tells if the target is newer than the source.

    Return true if 'source' exists and is more recently modified than
    'target', or if 'source' exists and 'target' doesn't.

    Return false if both exist and 'target' is the same age or younger
    than 'source'. Raise DistutilsFileError if 'source' does not exist.

    Note that this test is not very accurate: files created in the same second
    will have the same "age".
    """
    if not os.path.exists(source):
        raise DistutilsFileError("file '%s' does not exist" %
                                 os.path.abspath(source))
    if not os.path.exists(target):
        return True

    return os.stat(source)[ST_MTIME] > os.stat(target)[ST_MTIME] 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:21,代碼來源:dep_util.py

示例7: __getitem__

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def __getitem__(self,key):
        """ db['key'] reading """
        fil = self.root / key
        try:
            mtime = (fil.stat()[stat.ST_MTIME])
        except OSError:
            raise KeyError(key)

        if fil in self.cache and mtime == self.cache[fil][1]:
            return self.cache[fil][0]
        try:
            # The cached item has expired, need to read
            with fil.open("rb") as f:
                obj = pickle.loads(f.read())
        except:
            raise KeyError(key)

        self.cache[fil] = (obj,mtime)
        return obj 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:21,代碼來源:pickleshare.py

示例8: checksum_directory

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def checksum_directory(directory, touch_first=False):
    """
    Walk directory structure and return simple checksum based on
    file size and modified time.
    """
    file_checksums = []
    fileL = glob.glob( os.path.join(directory,'*.rst') )
    
    for source_path in fileL:
    
        if touch_first: # 
            os.utime(source_path, None)
            
        try:
            stats = os.stat(source_path)
        except OSError:
            # ignore temp files and files we don't
            # have perms to access
            continue
        file_checksums.append(
            stats[stat.ST_SIZE] + stats[stat.ST_MTIME])
    return sum(file_checksums) 
開發者ID:sonofeft,項目名稱:RocketCEA,代碼行數:24,代碼來源:sphinxy.py

示例9: newer

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def newer (source, target):
    """Return true if 'source' exists and is more recently modified than
    'target', or if 'source' exists and 'target' doesn't.  Return false if
    both exist and 'target' is the same age or younger than 'source'.
    Raise DistutilsFileError if 'source' does not exist.
    """
    if not os.path.exists(source):
        raise DistutilsFileError("file '%s' does not exist" %
                                 os.path.abspath(source))
    if not os.path.exists(target):
        return 1

    from stat import ST_MTIME
    mtime1 = os.stat(source)[ST_MTIME]
    mtime2 = os.stat(target)[ST_MTIME]

    return mtime1 > mtime2

# newer () 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:21,代碼來源:dep_util.py

示例10: show_statistics

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def show_statistics(self):
        """Show general file and table statistics
        """

        print "# File Statistics:"
        file_stats = os.stat(self.frm_path)
        file_info = {
            'Size': file_stats[stat.ST_SIZE],
            'Last Modified': time.ctime(file_stats[stat.ST_MTIME]),
            'Last Accessed': time.ctime(file_stats[stat.ST_ATIME]),
            'Creation Time': time.ctime(file_stats[stat.ST_CTIME]),
            'Mode': file_stats[stat.ST_MODE],
        }
        for value, data in file_info.iteritems():
            print "#%22s : %s" % (value, data)
        print

        # Fail if we cannot read the file
        try:
            self.frm_file = open(self.frm_path, "rb")
        except Exception, error:
            raise UtilError("The file %s cannot be read.\n%s" %
                            (self.frm_path, error))

        # Read the file type 
開發者ID:mysql,項目名稱:mysql-utilities,代碼行數:27,代碼來源:frm_reader.py

示例11: startViewer

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def startViewer(self, Form):
    self.screen = 4

    if(self.isLive):
      self.isLive=False
      self.tplImage = "init.png"
      if not fotoboxCfg['nopi']:
        self.camera.stop_preview()

    self.entries = None
    self.entries = (os.path.join(self.save, fn) for fn in os.listdir(self.save))
    self.entries = ((os.stat(path), path) for path in self.entries)
    self.entries = ((stat[ST_MTIME], path)
      for stat, path in self.entries if S_ISREG(stat[ST_MODE]))
    self.entries = list(self.entries)

    if(len(self.entries) > 0):
      self.viewerIndex = 0
      self.screenViewer(Form)
    else:
      print("No images to show")
      self.screenMain(Form) 
開發者ID:adlerweb,項目名稱:fotobox,代碼行數:24,代碼來源:fotobox.py

示例12: _compile_from_file

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def _compile_from_file(self, path, filename):
        if path is not None:
            util.verify_directory(os.path.dirname(path))
            filemtime = os.stat(filename)[stat.ST_MTIME]
            if (
                not os.path.exists(path)
                or os.stat(path)[stat.ST_MTIME] < filemtime
            ):
                data = util.read_file(filename)
                _compile_module_file(
                    self, data, filename, path, self.module_writer
                )
            module = compat.load_module(self.module_id, path)
            del sys.modules[self.module_id]
            if module._magic_number != codegen.MAGIC_NUMBER:
                data = util.read_file(filename)
                _compile_module_file(
                    self, data, filename, path, self.module_writer
                )
                module = compat.load_module(self.module_id, path)
                del sys.modules[self.module_id]
            ModuleInfo(module, path, self, filename, None, None, None)
        else:
            # template filename and no module directory, compile code
            # in memory
            data = util.read_file(filename)
            code, module = _compile_text(self, data, filename)
            self._source = None
            self._code = code
            ModuleInfo(module, None, self, filename, code, None, None)
        return module 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:33,代碼來源:template.py

示例13: get_modified_time

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def get_modified_time(self):
        """返回 ``self.absolute_path`` 的最後修改時間.

        可以被子類複寫. 應當返回一個 `~datetime.datetime`
        對象或None.

        .. versionadded:: 3.1
        """
        stat_result = self._stat()
        modified = datetime.datetime.utcfromtimestamp(
            stat_result[stat.ST_MTIME])
        return modified 
開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:14,代碼來源:web.py

示例14: _compile_from_file

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def _compile_from_file(self, path, filename):
        if path is not None:
            util.verify_directory(os.path.dirname(path))
            filemtime = os.stat(filename)[stat.ST_MTIME]
            if not os.path.exists(path) or \
                    os.stat(path)[stat.ST_MTIME] < filemtime:
                data = util.read_file(filename)
                _compile_module_file(
                    self,
                    data,
                    filename,
                    path,
                    self.module_writer)
            module = compat.load_module(self.module_id, path)
            del sys.modules[self.module_id]
            if module._magic_number != codegen.MAGIC_NUMBER:
                data = util.read_file(filename)
                _compile_module_file(
                    self,
                    data,
                    filename,
                    path,
                    self.module_writer)
                module = compat.load_module(self.module_id, path)
                del sys.modules[self.module_id]
            ModuleInfo(module, path, self, filename, None, None)
        else:
            # template filename and no module directory, compile code
            # in memory
            data = util.read_file(filename)
            code, module = _compile_text(
                self,
                data,
                filename)
            self._source = None
            self._code = code
            ModuleInfo(module, None, self, filename, code, None)
        return module 
開發者ID:jpush,項目名稱:jbox,代碼行數:40,代碼來源:template.py

示例15: getmtime

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_MTIME [as 別名]
def getmtime(self):
        st = self.stat()
        if st: 
            return st[stat.ST_MTIME]
        else: 
            return None 
開發者ID:Autodesk,項目名稱:arnold-usd,代碼行數:8,代碼來源:FS.py


注:本文中的stat.ST_MTIME屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。