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