本文整理汇总了Python中os.path.getctime方法的典型用法代码示例。如果您正苦于以下问题:Python path.getctime方法的具体用法?Python path.getctime怎么用?Python path.getctime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类os.path
的用法示例。
在下文中一共展示了path.getctime方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: date_created
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def date_created(self, format: str="%A, %B %d, %Y") -> str:
date = None
try:
date = datetime.strptime(self.metadata.InstanceCreationDate+str(round(float(self.metadata.InstanceCreationTime))), "%Y%m%d%H%M%S")
date = date.strftime(format)
except (AttributeError, ValueError):
try:
date = datetime.strptime(self.metadata.StudyDate, "%Y%m%d")
date = date.strftime(format)
except:
pass
if date is None:
try:
date = datetime.fromtimestamp(osp.getctime(self.path)).strftime(format)
except AttributeError:
date = 'Unknown'
return date
示例2: _file_timestamp
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def _file_timestamp(filename):
"""Gets the last created timestamp of the file/dir."""
if platform.system() == 'Windows':
ts = int(path.getctime(filename))
else:
stat = os.stat(filename)
if hasattr(stat, 'st_birthtime'): # odx
ts = int(stat.st_birthtime)
else:
ts = int(stat.st_mtime) # linux
return ts
示例3: get_dates
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def get_dates(path):
try:
created = datetime.fromtimestamp(getctime(path)).strftime('%d %b %Y, %H:%M:%S')
except OSError as e:
created = e
try:
accessed = datetime.fromtimestamp(getatime(path)).strftime('%d %b %Y, %H:%M:%S')
except OSError as e:
accessed = e
try:
modified = datetime.fromtimestamp(getmtime(path)).strftime('%d %b %Y, %H:%M:%S')
except OSError as e:
modified = e
return created, accessed, modified
示例4: find_latest_local
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def find_latest_local(self):
"""
>>> self = Deployer()
>>> self.find_pretrained()
>>> self.find_latest_local()
"""
from os.path import getctime
task_clf_candidates = self.find_pretrained()
task_clf_fpaths = {}
for task_key, fpaths in task_clf_candidates.items():
# Find the classifier most recently created
fpath = fpaths[ut.argmax(map(getctime, fpaths))]
task_clf_fpaths[task_key] = fpath
return task_clf_fpaths
示例5: __del__
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def __del__(self):
if not isdir(self.dir_cache):
return
for file_cache in listdir(self.dir_cache):
diff_time = (datetime.now() - datetime.fromtimestamp(getctime(self.dir_cache + file_cache)))
if diff_time.seconds >= self.cache_timeout:
remove(self.dir_cache + file_cache)
self.save_cookie()
示例6: getctime
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def getctime(path=("StringPin", "", {PinSpecifires.INPUT_WIDGET_VARIANT: "PathWidget"})):
'''Return the system’s ctime which, on some systems (like Unix) is the time of the last metadata change, and, on others (like Windows), is the creation time for path. The return value is a number giving the number of seconds since the epoch (see the time module). Raise os.error if the file does not exist or is inaccessible.'''
return osPath.getctime(path, path2)
示例7: getsize
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def getsize(path=("StringPin", "", {PinSpecifires.INPUT_WIDGET_VARIANT: "PathWidget"})):
'''Return the size, in bytes, of path. Raise os.error if the file does not exist or is inaccessible.'''
return osPath.getctime(path, path2)
示例8: get_update_time
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def get_update_time(self):
try:
from os.path import getctime
from datetime import datetime
self.update_utc_time = datetime.utcfromtimestamp(getctime(self.ANSIBLE_PULL_LOG_FILE))
except:
pass
示例9: __init__
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def __init__(self, pid):
self.pid = pid
self.running = True
self.ended_datetime = None
# Mapping of each status_fields to value from the status file.
# Initialize fields to zero in case info() is called.
self.status = {field: 0 for field in self.status_fields}
self.path = path = P.join(PROC_DIR, str(pid))
if not P.exists(path):
raise NoProcessFound(pid)
self.status_path = P.join(path, 'status')
# Get the command that started the process
with open(P.join(path, 'cmdline'), encoding='utf-8') as f:
cmd = f.read()
# args are separated by \x00 (Null byte)
self.command = cmd.replace('\x00', ' ').strip()
if self.command == '':
# Some processes (such as kworker) have nothing in cmdline, read comm instead
with open(P.join(path, 'comm')) as comm_file:
self.command = self.executable = comm_file.read().strip()
else:
# Just use 1st arg instead of reading comm
self.executable = self.command.split()[0]
# Get the start time (/proc/PID file creation time)
self.created_datetime = datetime.fromtimestamp(P.getctime(path))
self.check()
示例10: created_time
# 需要导入模块: from os import path [as 别名]
# 或者: from os.path import getctime [as 别名]
def created_time(self, name):
return datetime.fromtimestamp(path.getctime(self.path(name)))