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


Python stat.ST_ATIME屬性代碼示例

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


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

示例1: show_statistics

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [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

示例2: test_only_new

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [as 別名]
def test_only_new(self):
        restoreFile = os.path.join(self.include.name, 'test')
        self.prepairFileInfo(restoreFile)
        with open(restoreFile, 'wt') as f:
            f.write('fooooooooooooooooooo')

        # change mtime to be newer than the one in snapshot
        st = os.stat(restoreFile)
        atime = st[stat.ST_ATIME]
        mtime = st[stat.ST_MTIME]
        new_mtime = mtime + 3600
        os.utime(restoreFile, (atime, new_mtime))

        self.sn.restore(self.sid, restoreFile, only_new = True)
        self.assertIsFile(restoreFile)
        with open(restoreFile, 'rt') as f:
            self.assertEqual(f.read(), 'fooooooooooooooooooo') 
開發者ID:bit-team,項目名稱:backintime,代碼行數:19,代碼來源:test_restore.py

示例3: last_access_time

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [as 別名]
def last_access_time(path):
    """
    Return the number of seconds since the epoch of the last access of a
    given file.

    """
    return os.stat(path)[stat.ST_ATIME] 
開發者ID:muhanzhang,項目名稱:D-VAE,代碼行數:9,代碼來源:cmodule.py

示例4: get_file_info

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [as 別名]
def get_file_info(system, path, verbose=False):
    fullpath = get_fullpath(system, path)
    if fullpath == IO_ERROR:
        return IO_ERROR
    
    result = {}    
    if system.startswith('/'): # local or sub
        if can_read(system, path):
            # TODO platform-specific
            stats = os.stat(fullpath)
            stm = stats.st_mode
            result['type'] = get_file_type_char(stat.S_IFMT(stm))
            result['permissions'] = '%o' % (stat.S_IMODE(stm))
            result['UID'] = stats[stat.ST_UID]
            result['GID'] = stats[stat.ST_GID]
            result['ATIME'] = stats[stat.ST_ATIME]
            result['MTIME'] = stats[stat.ST_MTIME]
            result['CTIME'] = stats[stat.ST_CTIME] # actually mtime on UNIX, TODO
        else:
            if verbose:
                log.info('File \'%s\' is not accessible.' % (fullpath))
            result['type'] = None
            result['permissions'] =  None
            result['UID'] = None
            result['GID'] = None
            result['ATIME'] = None
            result['MTIME'] = None
            result['CTIME'] = None
        return result

    else: # SSH/FTP/TFTP/HTTP
        # TODO NOT IMPLEMENTED
        return IO_ERROR 
開發者ID:lightfaith,項目名稱:locasploit,代碼行數:35,代碼來源:io.py

示例5: updateModificationTime

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [as 別名]
def updateModificationTime(path):
    accessTime = os.stat(path)[stat.ST_ATIME]
    modificationTime = time.time()
    os.utime(path, (accessTime, modificationTime)) 
開發者ID:luoliyan,項目名稱:incremental-reading,代碼行數:6,代碼來源:util.py

示例6: getatime

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [as 別名]
def getatime(self):
        st = self.statinfo
        if not st:
            self.restat()
            st = self.statinfo
        return st[ST_ATIME] 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:8,代碼來源:filepath.py

示例7: _write_infos_to_temp

# 需要導入模塊: import stat [as 別名]
# 或者: from stat import ST_ATIME [as 別名]
def _write_infos_to_temp(temp_folder, original_stat, infos):
  times = (original_stat[stat.ST_ATIME], original_stat[stat.ST_MTIME])

  for name, info in infos.items():
    out = os.path.join(temp_folder, name)
    with open(out, 'w') as f:
      f.write(info)
    os.utime(out, times) 
開發者ID:JakeWharton,項目名稱:jardiff,代碼行數:10,代碼來源:jardiff.py


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