本文整理汇总了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)