本文整理匯總了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
示例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')
示例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]
示例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
示例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))
示例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]
示例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)