本文整理匯總了Python中time.asctime方法的典型用法代碼示例。如果您正苦於以下問題:Python time.asctime方法的具體用法?Python time.asctime怎麽用?Python time.asctime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類time
的用法示例。
在下文中一共展示了time.asctime方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def run(self):
print("Start try ssh => %s" % self.ip)
username = "root"
try:
password = open(self.dict).read().split('\n')
except:
print("Open dict file `%s` error" % self.dict)
exit(1)
for pwd in password:
try:
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(self.ip, self.port, username, pwd, timeout = self.timeout)
print("\nIP => %s, Login %s => %s \n" % (self.ip, username, pwd))
open(self.LogFile, "a").write("[ %s ] IP => %s, port => %d, %s => %s \n" % (time.asctime( time.localtime(time.time()) ), self.ip, self.port, username, pwd))
break
except:
print("IP => %s, Error %s => %s" % (self.ip, username, pwd))
pass
示例2: write_version_py
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def write_version_py():
content = """# GENERATED VERSION FILE
# TIME: {}
__version__ = '{}'
short_version = '{}'
version_info = ({})
"""
sha = get_hash()
with open('mmdet/VERSION', 'r') as f:
SHORT_VERSION = f.read().strip()
VERSION_INFO = ', '.join(SHORT_VERSION.split('.'))
VERSION = SHORT_VERSION + '+' + sha
version_file_str = content.format(time.asctime(), VERSION, SHORT_VERSION,
VERSION_INFO)
with open(version_file, 'w') as f:
f.write(version_file_str)
示例3: _install_message
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def _install_message(self, message):
"""Format a message and blindly write to self._file."""
from_line = None
if isinstance(message, str) and message.startswith('From '):
newline = message.find('\n')
if newline != -1:
from_line = message[:newline]
message = message[newline + 1:]
else:
from_line = message
message = ''
elif isinstance(message, _mboxMMDFMessage):
from_line = 'From ' + message.get_from()
elif isinstance(message, email.message.Message):
from_line = message.get_unixfrom() # May be None.
if from_line is None:
from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
start = self._file.tell()
self._file.write(from_line + os.linesep)
self._dump_message(message, self._file, self._mangle_from_)
stop = self._file.tell()
return (start, stop)
示例4: doSearch
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def doSearch(self):
self.dp = dirpath(self.dirpattern, self.recurse)
self.SetTitle("Pychecker Run '%s' (options: %s)" % (self.filpattern, self.greppattern))
#self.text = []
self.GetFirstView().Append('#Pychecker Run in '+self.dirpattern+' %s\n'%time.asctime())
if self.verbose:
self.GetFirstView().Append('# ='+repr(self.dp.dirs)+'\n')
self.GetFirstView().Append('# Files '+self.filpattern+'\n')
self.GetFirstView().Append('# Options '+self.greppattern+'\n')
self.fplist = self.filpattern.split(';')
self.GetFirstView().Append('# Running... ( double click on result lines in order to jump to the source code ) \n')
win32ui.SetStatusText("Pychecker running. Please wait...", 0)
self.dpndx = self.fpndx = 0
self.fndx = -1
if not self.dp:
self.GetFirstView().Append("# ERROR: '%s' does not resolve to any search locations" % self.dirpattern)
self.SetModifiedFlag(0)
else:
##self.flist = glob.glob(self.dp[0]+'\\'+self.fplist[0])
import operator
self.flist = reduce(operator.add, list(map(glob.glob,self.fplist)) )
#import pywin.debugger;pywin.debugger.set_trace()
self.startPycheckerRun()
示例5: VssLog
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def VssLog(project, linePrefix = "", noLabels = 5, maxItems=150):
lines = []
num = 0
labelNum = 0
for i in project.GetVersions(constants.VSSFLAG_RECURSYES):
num = num + 1
if num > maxItems : break
commentDesc = itemDesc = ""
if i.Action[:5]=="Added":
continue
if len(i.Label):
labelNum = labelNum + 1
itemDesc = i.Action
else:
itemDesc = i.VSSItem.Name
if str(itemDesc[-4:])==".dsp":
continue
if i.Comment:
commentDesc ="\n%s\t%s" % (linePrefix, i.Comment)
lines.append("%s%s\t%s%s" % (linePrefix, time.asctime(time.localtime(int(i.Date))), itemDesc, commentDesc))
if labelNum > noLabels:
break
return string.join(lines,"\n")
示例6: SubstituteVSSInFile
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def SubstituteVSSInFile(projectName, inName, outName):
import win32api
if win32api.GetFullPathName(inName)==win32api.GetFullPathName(outName):
raise RuntimeError("The input and output filenames can not be the same")
sourceSafe=GetSS()
project = sourceSafe.VSSItem(projectName)
# Find the last label
label = None
for version in project.Versions:
if version.Label:
break
else:
print "Couldnt find a label in the sourcesafe project!"
return
# Setup some local helpers for the conversion strings.
vss_label = version.Label
vss_date = time.asctime(time.localtime(int(version.Date)))
now = time.asctime(time.localtime(time.time()))
SubstituteInFile(inName, outName, (locals(),globals()))
示例7: helpmsg
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def helpmsg():
volubility = len(sys.argv)
# merge list word items to one string line
_stringargv = " ".join(sys.argv)
print "\n ********************************************** "
print " *** TEST OpenTSDB put *** "
print " *** By 3POKang *** "
print " ********************************************** "
timestamp=time.localtime()
print " Thanks for the try, time : ", time.asctime(timestamp) , \
" >> Volubility, Arg length = ", volubility
if volubility > 1:
argv1 = sys.argv[1]
print " sys.argv[%d] = %s" % (1, argv1) ,
else :
exit (" you should input the IP address of openTSDB server like 10.0.0.1:4242")
return argv1
示例8: __init__
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def __init__(self, data):
weather = data['weather'][0]
self.id = weather['id']
self.main = weather['main']
if len(weather['description']) >= 16:
self.description = weather['description'][0:16]
else:
self.description = weather['description']
if self.id in WEATHER_MAPE:
self.weather_icon = copy.deepcopy(WEATHER_ICON[WEATHER_MAPE[self.id]])
else:
self.weather_icon = copy.deepcopy(WEATHER_ICON['unknown'])
self.dt = data['dt']
self.date = time.asctime(time.localtime(self.dt))[0:10]
self.data = data
示例9: init_sqlconn
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def init_sqlconn(i, source):
mark = True
while mark:
print(
source + ':' + time.asctime(time.localtime(time.time())) + ':',
end='')
try:
conn = v2server.sqlconn()
if i == 0:
print('Mysql Connection Successfully')
elif i == 1:
print('Mysql Connection Successfully Recovered')
mark = False
except Exception:
print('Mysql Connection Error')
time.sleep(10)
continue
return conn
# AES模塊
示例10: log_recent
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def log_recent(conn, name, message, severity=logging.INFO, pipe=None):
severity = str(SEVERITY.get(severity, severity)).lower() #B
destination = 'recent:%s:%s'%(name, severity) #C
message = time.asctime() + ' ' + message #D
pipe = pipe or conn.pipeline() #E
pipe.lpush(destination, message) #F
pipe.ltrim(destination, 0, 99) #G
pipe.execute() #H
# <end id="recent_log"/>
#A Set up a mapping that should help turn most logging severity levels into something consistent
#B Actually try to turn a logging level into a simple string
#C Create the key that messages will be written to
#D Add the current time so that we know when the message was sent
#E Set up a pipeline so we only need 1 round trip
#F Add the message to the beginning of the log list
#G Trim the log list to only include the most recent 100 messages
#H Execute the two commands
#END
# <start id="common_log"/>
開發者ID:fuqi365,項目名稱:https---github.com-josiahcarlson-redis-in-action,代碼行數:22,代碼來源:ch05_listing_source.py
示例11: _to_bel_lines_header
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def _to_bel_lines_header(graph) -> Iterable[str]:
"""Iterate the lines of a BEL graph's corresponding BEL script's header.
:param pybel.BELGraph graph: A BEL graph
"""
yield '# This document was created by PyBEL v{} and bel-resources v{} on {}\n'.format(
VERSION, bel_resources.constants.VERSION, time.asctime(),
)
yield from make_knowledge_header(
namespace_url=graph.namespace_url,
namespace_patterns=graph.namespace_pattern,
annotation_url=graph.annotation_url,
annotation_patterns=graph.annotation_pattern,
annotation_list=graph.annotation_list,
**graph.document,
)
示例12: print_with_tag
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def print_with_tag(tag, data ,debug=0):
data_print = data
if type(data) == list:
data_print = ''
for per_data in data:
if len(data_print) == 0:
data_print += str(per_data)
else:
data_print += ' ' + str(per_data)
if debug == 1:
print('[' + time.asctime(time.localtime(time.time())) + '] ' + tag + ' =>', data_print)
else:
print(data_print)
示例13: report
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def report(self):
txt = '\n[CLOCK] [ {} ] '
txt += 'since start: [ {} ] since last: [ {} ]\n'
current = time.asctime().split()[3]
since_start = datetime.timedelta(seconds=round(self.now - self.start))
since_last = datetime.timedelta(seconds=round(self.now - self.last))
logger.info(txt.format(current, since_start, since_last))
示例14: generate_compiled_code
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def generate_compiled_code(self):
buffer = StringIO()
emitter = ksp_ast.Emitter(buffer, compact=self.compact)
self.module.emit(emitter)
self.compiled_code = buffer.getvalue()
# NOTE(Sam): Add a ksp comment at the beginning of the compiled script to display the time and date it was compiled on
if self.add_compiled_date_comment:
localtime = time.asctime( time.localtime(time.time()) )
self.compiled_code = "{ Compiled on " + localtime + " }\n" + self.compiled_code
示例15: _writeVcdHeader
# 需要導入模塊: import time [as 別名]
# 或者: from time import asctime [as 別名]
def _writeVcdHeader(f, timescale):
print("$date", file=f)
print(" %s" % time.asctime(), file=f)
print("$end", file=f)
print("$version", file=f)
print(" MyHDL %s" % __version__, file=f)
print("$end", file=f)
print("$timescale", file=f)
print(" %s" % timescale, file=f)
print("$end", file=f)
print(file=f)