本文整理匯總了Python中datetime.datetime.ctime方法的典型用法代碼示例。如果您正苦於以下問題:Python datetime.ctime方法的具體用法?Python datetime.ctime怎麽用?Python datetime.ctime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類datetime.datetime
的用法示例。
在下文中一共展示了datetime.ctime方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ctime
# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import ctime [as 別名]
def ctime():
"""Return a string representing the date.
For example date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'.
d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple()))
on platforms where the native C ctime() function
(which time.ctime() invokes, but which date.ctime() does not invoke)
conforms to the C standard.
"""
示例2: ctime
# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import ctime [as 別名]
def ctime():
"""Return a string representing the date.
For example date(2002, 12, 4).ctime() == 'Wed Dec 4 00:00:00 2002'.
d.ctime() is equivalent to time.ctime(time.mktime(d.timetuple()))
on platforms where the native C ctime() function
(which `time.ctime` invokes, but which date.ctime() does not invoke)
conforms to the C standard.
"""
示例3: selftest_function
# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import ctime [as 別名]
def selftest_function(opts):
"""
Placeholder for selftest function. An example use would be to test package api connectivity.
Suggested return values are be unimplemented, success, or failure.
"""
options = opts.get("fn_teams", {})
# determine if self test is enabled
if not options.get(SELF_TEST):
return {
"state": "unimplemented",
"reason": "{} not found in app.config".format((SELF_TEST))
}
else:
webhook = options.get(SELF_TEST)
try:
card = pymsteams.connectorcard(webhook, http_proxy=opts['proxy_http'] if opts.get('proxy_http') else None,
https_proxy=opts['proxy_https'] if opts.get('proxy_https') else None,
http_timeout=60)
card.title("Resilient SelfTest")
card.text(datetime.ctime(datetime.now()))
card.send()
return {
"state": "success",
"reason": None
}
except Exception as err:
log.error(err.message)
return {
"state": "failure",
"reason": err.message if err.message else None
}
示例4: create_logger
# 需要導入模塊: from datetime import datetime [as 別名]
# 或者: from datetime.datetime import ctime [as 別名]
def create_logger(level=logging.NOTSET):
"""Create a logger for python-gnupg at a specific message level.
:type level: :obj:`int` or :obj:`str`
:param level: A string or an integer for the lowest level to include in
logs.
**Available levels:**
==== ======== ========================================
int str description
==== ======== ========================================
0 NOTSET Disable all logging.
9 GNUPG Log GnuPG's internal status messages.
10 DEBUG Log module level debuging messages.
20 INFO Normal user-level messages.
30 WARN Warning messages.
40 ERROR Error messages and tracebacks.
50 CRITICAL Unhandled exceptions and tracebacks.
==== ======== ========================================
"""
_test = os.path.join(os.path.join(os.getcwd(), 'gnupg'), 'test')
_now = datetime.now().strftime("%Y-%m-%d_%H%M%S")
_fn = os.path.join(_test, "%s_test_gnupg.log" % _now)
_fmt = "%(relativeCreated)-4d L%(lineno)-4d:%(funcName)-18.18s %(levelname)-7.7s %(message)s"
## Add the GNUPG_STATUS_LEVEL LogRecord to all Loggers in the module:
logging.addLevelName(GNUPG_STATUS_LEVEL, "GNUPG")
logging.Logger.status = status
if level > logging.NOTSET:
logging.basicConfig(level=level, filename=_fn,
filemode="a", format=_fmt)
logging.logThreads = True
if hasattr(logging,'captureWarnings'):
logging.captureWarnings(True)
colouriser = _ansistrm.ColorizingStreamHandler
colouriser.level_map[9] = (None, 'blue', False)
colouriser.level_map[10] = (None, 'cyan', False)
handler = colouriser(sys.stderr)
handler.setLevel(level)
formatr = logging.Formatter(_fmt)
handler.setFormatter(formatr)
else:
handler = NullHandler()
log = logging.getLogger('gnupg')
log.addHandler(handler)
log.setLevel(level)
log.info("Log opened: %s UTC" % datetime.ctime(datetime.utcnow()))
return log