本文整理汇总了Python中time.time.strftime函数的典型用法代码示例。如果您正苦于以下问题:Python strftime函数的具体用法?Python strftime怎么用?Python strftime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了strftime函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: InsertKeyWordToDB
def InsertKeyWordToDB(fromSubDir,toSubDir):
db = DB()
parser = Parser()
for index in range(fromSubDir,toSubDir):
for root,dirs,files in os.walk('test/keyword/'+str(index)+"/"):
#each subdir: 1000record
start = time.time()
for afile in files:
if afile == '.DS_Store':
continue
words = afile.split('_')
aExpert = Expert(words[0].strip(),words[1].strip(),words[2].replace(".html","").strip())
aExpert.setKeyword(parser.parseKeyword(root,afile))
aExpert.ChangeKeywordsToString()
#print aExpert.keywordsList
if not db.isExpertExist(aExpert):
db.insertExpert(aExpert)
end = time.time()
db.conn.commit()
print ("KeywordSubDir %d is Done!"%index),
print time.strftime('%m-%d %H:%M:%S',time.localtime(time.time())),"total:",end-start
f = open("KeywordsToDB.log","a")
f.write(time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))+" keywordSubDir"+str(index)+" is Done! "+"total"+str(end-start) )
f.close()
db.close()
开发者ID:CharlesZhong,项目名称:CnkiProject,代码行数:30,代码来源:CnkiParser.py
示例2: InsertPaperToDB
def InsertPaperToDB(fromSubDir,toSubDir):
db = DB()
parser = Parser()
for index in range(fromSubDir,toSubDir):
for root,dirs,files in os.walk('test/paper/'+str(index)+"/"):
n = 1000*index
start = time.time()
for afile in files:
if afile == '.DS_Store':
continue
words = afile.split('_')
papers = (parser.parsePaper(root,afile))
for eachPapaer in papers:
if not db.isPaperExist(eachPapaer):
db.insertPaper(eachPapaer)
print "n:",n,
print "Expert_ID %s is done"%words[0]
n = n + 1
db.conn.commit()
end = time.time()
print ("PaperSubDir %d is Done!"%index),
print time.strftime('%m-%d %H:%M:%S',time.localtime(time.time())),"time:",end-start,
f = open("PaperToDB.log","a")
f.write(time.strftime('%m-%d %H:%M:%S',time.localtime(time.time()))+" paperSubDir"+str(index)+" is Done! "+"total"+str(end-start) )
f.close()
db.close()
开发者ID:CharlesZhong,项目名称:CnkiProject,代码行数:29,代码来源:CnkiParser.py
示例3: getStatus
def getStatus(session_id, host_id):
"""Returns a dictionary describing the status of the host"""
# Get some basic info
hostname = getHostName(session_id, host_id)
hoststatus = getHostStatus(hostname)
# Get the host's CFengine status
status = getCfengineHostStatus(session_id, hoststatus.host._properties)
# Get state information
status["reachable"] = hoststatus.reachable
status["operating_rev"] = hoststatus.operatingRevision
status["operating_rev_status"] = hoststatus.operatingRevisionStatus
status["operating_rev_text"] = hoststatus.operatingRevisionText
status["operating_rev_hint"] = hoststatus.operatingRevisionHint
status["active_rev"] = hoststatus.activeRevision
status["generated_rev"] = hoststatus.generatedRevision
status["current_load"] = hoststatus.currentLoad
status["uptime"] = hoststatus.uptime
status["infoUpdatedAt"] = time.strftime("%d/%m/%Y %H:%M:%S", \
time.localtime(hoststatus.infoUpdatedAt))
status["lastCheckedAt"] = time.strftime("%d/%m/%Y %H:%M:%S", \
time.localtime(hoststatus.lastCheckedAt))
return status
开发者ID:libzz,项目名称:amiral,代码行数:26,代码来源:ccs_status.py
示例4: Update
def Update(self):
saat = str(config.plugins.TimeSet.UTCTim.value[0])
if len(saat) < 2:
saat = '0' + saat
minuti = str(config.plugins.TimeSet.UTCTim.value[1])
if len(minuti) < 2:
minuti = '0' + minuti
sekunde = strftime('%S', localtime())
pp = config.plugins.TimeSet.NDate.value
import time
TimeString = time.strftime('%Y%m%d', time.gmtime(pp)) + saat + minuti + sekunde
RTCString = time.strftime('%Y.%m.%d', time.gmtime(pp)) + '-' + saat + ':' + minuti + ':' + sekunde
TimeZoneS = config.timezone.val.value
ipos1 = TimeZoneS.find('(GMT')
ipos2 = TimeZoneS.find(')')
tmp = TimeZoneS[ipos1 + 4:ipos2]
if len(tmp) == 0:
tmp = '+00'
tzpredznak = tmp[:1]
tzvalue = str(int(tmp[1:3]))
TimeString = TimeString + tzpredznak + tzvalue
import os as os
cmd = 'echo "' + str(TimeString) + '" > /proc/settime'
os.system(cmd)
cmd = 'date -u -s "' + str(RTCString) + '"'
os.system(cmd)
self.session.openWithCallback(self.callback, MessageBox, _('RTC Update done! \n\nGUI Clock Update done!'), type = 1, timeout = 5)
开发者ID:OpenAZBox,项目名称:RTi-Old,代码行数:30,代码来源:plugin.py
示例5: friendtime
def friendtime(dt,format='%Y-%m-%d %H:%M'):
'''时间友好显示化'''
t = time.localtime(time.time())
today = time.mktime(time.strptime(time.strftime('%Y-%m-%d 00:00:00', t),'%Y-%m-%d %H:%M:%S'))
yestoday = today - 3600*24
if dt > today:
return u'今天' + time.strftime('%H:%M',time.localtime(dt))
if dt > yestoday and dt < today:
return u'昨天' + time.strftime('%H:%M',time.localtime(dt))
return time.strftime(format,time.localtime(dt))
开发者ID:fchypzero,项目名称:Instagram4sae,代码行数:10,代码来源:util.py
示例6: procdt
def procdt(self,args=None):
view=self.view
edit=self.edit
dicdt={'dt':'TM_TH_DTTM','date':'TM_TH_DATE','time':'TM_TH_TIME'}
ctime=time.localtime(time.time())
dicvl={'dt':time.strftime('%Y/%m/%d %H:%M:%S',ctime),'date':time.strftime('%Y/%m/%d',ctime),'time':time.strftime('%H/%M/%S',ctime)}
if not args==None:
mcdt='#'+dicdt[args]
reg_bb=view.find(mcdt,0)
view.replace(edit, reg_bb, dicvl[args])
开发者ID:Firef0x,项目名称:SublimeTextConfig,代码行数:10,代码来源:auto_file.py
示例7: Page
def Page(self):
plugin_path = '/usr/lib/enigma2/python/RTiTeam/TimeSet'
print plugin_path
before = 'Before: Local=' + strftime('%H:%M', localtime()) + ', UTC=' + strftime('%H:%M', gmtime())
cmd = str(plugin_path + '/ntpdate -t 20 0.debian.pool.ntp.org')
res = popen(cmd).read()
if res == '':
cmd = 'ls -l %s%s' % (plugin_path, '/ntpdate')
res = popen(cmd).read()
if res[3] != 'x':
cmd = 'chmod 755 %s%s' % (plugin_path, '/ntpdate')
res = popen(cmd).read()
self.session.open(MessageBox, _('ntpdate problem: attributes for ntpdate have not been correct! Fixed now! Try again!\n%s' % res), MessageBox.TYPE_INFO)
else:
self.session.open(MessageBox, _('ntpdate problem: Internet connection ok? Time server ok?'), MessageBox.TYPE_INFO)
else:
z1 = mktime(datetime.utcnow().timetuple())
config.plugins.TimeSet.NDate = ConfigDateTime(default = z1, formatstring = _('%d.%B %Y'), increment = 86400)
config.plugins.TimeSet.UTCTim = ConfigClock(default = z1)
self.list1 = []
self.list1.append(getConfigListEntry(_('UTC Time'), config.plugins.TimeSet.UTCTim))
self.list1.append(getConfigListEntry(_('Date'), config.plugins.TimeSet.NDate))
self['config'].setList(self.list1)
self.selectionChanged()
saat = str(config.plugins.TimeSet.UTCTim.value[0])
if len(saat) < 2:
saat = '0' + saat
minuti = str(config.plugins.TimeSet.UTCTim.value[1])
if len(minuti) < 2:
minuti = '0' + minuti
sekunde = strftime('%S', localtime())
pp = config.plugins.TimeSet.NDate.value
import time
TimeString = time.strftime('%Y%m%d', time.gmtime(pp)) + saat + minuti + sekunde
RTCString = time.strftime('%Y.%m.%d', time.gmtime(pp)) + '-' + saat + ':' + minuti + ':' + sekunde
TimeZoneS = config.timezone.val.value
ipos1 = TimeZoneS.find('(GMT')
ipos2 = TimeZoneS.find(')')
tmp = TimeZoneS[ipos1 + 4:ipos2]
if len(tmp) == 0:
tmp = '+00'
tzpredznak = tmp[:1]
tzvalue = str(int(tmp[1:3]))
TimeString = TimeString + tzpredznak + tzvalue
import os
cmd = 'echo "' + str(TimeString) + '" > /proc/settime'
os.system(cmd)
cmd = 'date -u -s "' + str(RTCString) + '"'
os.system(cmd)
self.session.openWithCallback(self.callback, MessageBox, _('RTC Update done! \n\nGUI Clock Update done!\n\n' + before + '\n\nntpdate done! ' + res + '\nAfter: Local=' + strftime('%H:%M', localtime()) + ', UTC=' + strftime('%H:%M', gmtime())), type = 1, timeout = 15)
开发者ID:OpenAZBox,项目名称:RTi-Old,代码行数:53,代码来源:plugin.py
示例8: getFormattedDate
def getFormattedDate(self, dt):
"""
returns a formatted date string
@summary: returns either the formatted datestring defined by DATE_FORMAT_STRING or it defaults to '%Y-%m-%d %H:%M:%S'.
@type dt: datetime
@param dt: datetime object to format
@rtype: string
@return: formatted date string
"""
if DATE_FORMAT_STRING == '':
return time.strftime('%Y-%m-%d %H:%M:%S', dt.timetuple())
else:
return time.strftime(DATE_FORMAT_STRING, dt.timetuple())
开发者ID:havvg,项目名称:mcxPyBot,代码行数:16,代码来源:mcxPyBot.py
示例9: ind_horario
def ind_horario(self, horario):
import time
# se consulta horario de dia actual
dweek = time.strftime("%a", time.localtime())
dsem = dweek[0:2].capitalize()
if dsem.find("Lu") != -1 or dsem.find("Mo") != -1:
ind = horario.find("Mo")
elif dsem.find("Ma") != -1 or dsem.find("Tu") != -1:
ind = horario.find("Tu")
elif dsem.find("Mi") != -1 or dsem.find("We") != -1:
ind = horario.find("We")
elif dsem.find("Ju") != -1 or dsem.find("Th") != -1:
ind = horario.find("Th")
elif dsem.find("Vi") != -1 or dsem.find("Fr") != -1:
ind = horario.find("Fr")
elif dsem.find("Sa") != -1 or dsem.find("Sa") != -1:
ind = horario.find("Sa")
elif dsem.find("Do") != -1 or dsem.find("Su") != -1:
ind = horario.find("Su")
else:
ind = -1
return ind
开发者ID:guadalinex-archive,项目名称:acept,代码行数:25,代码来源:informe.py
示例10: wrapper
def wrapper(*args, **kargs):
t1 = time.time()
res = func(*args, **kargs)
tel = time.time()-t1
timeformated = time.strftime( "%H:%M:%S",time.gmtime(tel))
print '-'*5 + '%s took %0.3f ms' % (func.func_name + str(kargs) + str(args), (tel)*1000.0) + '|' + timeformated + '|'+ '-'*10
return res
开发者ID:nickmilon,项目名称:milonpy,代码行数:7,代码来源:basic2.py
示例11: create_temporary_path
def create_temporary_path(self):
import time
from sct_utils import slash_at_the_end
path_tmp = slash_at_the_end("tmp." + time.strftime("%y%m%d%H%M%S"), 1)
sct.run("mkdir " + path_tmp, self.verbose)
return path_tmp
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:7,代码来源:sct_get_centerline.py
示例12: selectionChanged
def selectionChanged(self):
self['introduction'].setText(_('Your time = UTC Time + Your Time Zone'))
self['vreme'].setText(_('*Current Your Time: ' + str(datetime.now().strftime('%H:%M:%S'))))
saat = str(config.plugins.TimeSet.UTCTim.value[0])
if len(saat) < 2:
saat = '0' + saat
minuti = str(config.plugins.TimeSet.UTCTim.value[1])
if len(minuti) < 2:
minuti = '0' + minuti
sekunde = strftime('%S', localtime())
pp = config.plugins.TimeSet.NDate.value
import time
TimeString = time.strftime('%Y%m%d', time.gmtime(pp)) + saat + minuti + sekunde
TimeZoneS = config.timezone.val.value
ipos1 = TimeZoneS.find('(GMT')
ipos2 = TimeZoneS.find(')')
tmp = TimeZoneS[ipos1 + 4:ipos2]
if len(tmp) == 0:
tmp = '+00'
tzpredznak = tmp[:1]
tzvalue = str(int(tmp[1:3]))
TimeString = TimeString + tzpredznak + tzvalue
self['timez'].setText(_('Time Zone : ' + str(TimeZoneS)))
self['poraka'].setText(_('TimeString : ' + str(TimeString)))
novovreme = str(int(saat) + int(tzpredznak + tzvalue))
if len(novovreme) < 2:
novovreme = '0' + novovreme
novovreme = novovreme + ':' + minuti
self['vreme'].setText(_('Your Time (After Setting): ' + str(novovreme)))
开发者ID:OpenAZBox,项目名称:RTi-Old,代码行数:33,代码来源:plugin.py
示例13: run
def run(self):
t0 = (2013, 3, 26, 23, 0, 0, 0, 1, -1)
t0 = calendar.timegm(t0)
t1 = time.time()
announcement_frequency = 60*60
if t1 - self.last_run < announcement_frequency:
return
print 't1 - self.last_run:',t1 - self.last_run
print 'self.last_run:',self.last_run
self.last_run = int(t1- (int(t1) % announcement_frequency))
t = int(t1 - t0)
days = t // (3600 * 24)
#move it back one day
days -= 1
date = time.gmtime(t0 + (days * (3600 * 24)))
next_date = time.gmtime(t0 + ((days+1) * (3600 * 24)))
response = 'NOTICE: Sefira for \x031,9YESTERDAY\x03, {date}: *{count}* Days of the omer.' \
+ ' You can count until sunset on {next_date}.' \
+ ' WARNING: THIS IS ALPHA, DOUBLE CHECK THIS YOURSELF (http://goo.gl/hzY2v)'
response = response.format(date=time.strftime("%a NIGHT, %d %b %I:%M %p",date),
next_date=time.strftime("%a",next_date),
count=(days+1))
for bot in self.bot_factory.bots:
bot.msg(bot.factory.channel, response)
开发者ID:mkopinsky,项目名称:vilnet,代码行数:46,代码来源:botted.py
示例14: backup_db
def backup_db(self):
'''Backup/archive esget.db'''
arcname = os.path.join(self.dbarchivedir,
os.path.split(self.dbname)[1] +
"."+time.strftime("%Y-%m-%d_%H-%M"))
shutil.copy(self.dbname, arcname)
self._log.info("Archived {0}".format(self.dbname))
return()
开发者ID:hvwaldow,项目名称:esget,代码行数:8,代码来源:esget_db.py
示例15: hoy_mun
def hoy_mun(cod,name):
import datetime
import time
import json
#Conexion BBDD
conexion = conexion_bbdd()
db = conexion.othesoluciones1
#Redireccion en la paginacion de la pagina de reportes
if (cod=='reporte'):
return reporte(name)
#Busqueda de datos en coleccion: prediccionesAEMET
collection1 = db.prediccionesAEMET
print elimina_tildes(name.decode('utf-8'))
name2 = elimina_tildes(name.decode('utf-8'))
print name2
print cod
cursorHoyM1 = collection1.find_one({"Municipio": name2})
print time.strftime("%Y-%m-%d")
busquedaAEMET = cursorHoyM1[time.strftime("%Y-%m-%d")]
#Carga de imagenes del municipio
collection2 = db.imagenes
cursorHoyM2 = collection2.find_one({'municipio':name2})
print cursorHoyM2['filename_img_municipio']
print cursorHoyM2['filename_img_municipio_cam']
f1 = gridfs.GridFS(db,"images").get_version(cursorHoyM2['filename_img_municipio'])
plot_url_img = base64.b64encode(f1.read())
f2 = gridfs.GridFS(db,"images").get_version(cursorHoyM2['filename_img_municipio_cam'])
plot_url_img_cam = base64.b64encode(f2.read())
#Busqueda de datos en coleccion:calidad_aire_por_municipio
collection3= db.calidad_aire_por_municipio
cursor3 = collection3.find_one({'Municipio':name2})
#Carga de las noticias del dia
noticias_del_dia=cargaNoticias()
#Conexion BBDD
conexion.close()
return template("views/p_hoy_mun.tpl",name=name, busquedaAEMET=busquedaAEMET,plot_url_img=plot_url_img, plot_url_img_cam=plot_url_img_cam, noticias_del_dia=noticias_del_dia, cursor3=cursor3)
开发者ID:othesoluciones,项目名称:TFM,代码行数:45,代码来源:app.py
示例16: getHostStatusSummary
def getHostStatusSummary(session_id, host_name):
"""Returns an overall status for the host"""
status = {}
try:
hoststatus = getHostStatus(host_name)
except:
status = {"status":STATUS_UNKNOWN,"status_text":"UNKNOWN", \
"status_hint":"No status information available"}
return status
status["infoUpdatedAt"] = time.strftime("%d/%m/%Y %H:%M:%S", \
time.localtime(hoststatus.infoUpdatedAt))
status["lastCheckedAt"] = time.strftime("%d/%m/%Y %H:%M:%S", \
time.localtime(hoststatus.lastCheckedAt))
status["status"] = STATUS_OK
status["status_text"] = "UP"
status["status_hint"] = "Last checked at %s" % status["lastCheckedAt"]
if not hoststatus.reachable:
status["status"] = STATUS_CRITICAL
status["status_text"] = "Down"
status["status_hint"] = "Not seen since %s" % status["infoUpdatedAt"]
return status
if hoststatus.operatingRevisionStatus != STATUS_OK:
status["status"] = hoststatus.operatingRevisionStatus
status["status_text"] = hoststatus.operatingRevisionText
status["statux_hint"] = hoststatus.operatingRevisionHint
return status
cstatus = getCfengineHostStatus(session_id, hoststatus.host._properties)
if cstatus["ssh_key_status"] != STATUS_OK:
status["status"] = cstatus["ssh_key_status"]
status["status_text"] = "SSH Key Error"
status["status_hint"] = cstatus["ssh_key_text"]
return status
if cstatus["cfengine_key_status"] != STATUS_OK:
status["status"] = cstatus["cfengine_key_status"]
status["status_text"] = "CFengine Key Error"
status["status_hint"] = cstatus["cfengine_key_text"]
return status
return status
开发者ID:libzz,项目名称:amiral,代码行数:44,代码来源:ccs_status.py
示例17: d_print
def d_print(*args):
import time
if MDEBUG:
if MDEBUG_TIMESTAMP:
s = '%s - ' % time.strftime('%H:%M:%S',time.localtime())
else:
s = ''
for arg in args:
s += str(arg)
print s
开发者ID:schleichdi2,项目名称:OpenNfr_E2_Gui-5.3,代码行数:10,代码来源:twagenthelper.py
示例18: insertExpert
def insertExpert(self,expert):
sql = "insert into GeniusExpert(Expert_ID,Expert_name,Expert_keywords) values('%s','%s','%s')" %(expert.expertID,expert.name,str(expert.keywordsList))
try:
#print sql
self.cursor.execute(sql)
except Exception, e:
f = open("ExpertError.log","a")
f.write(str(e)+"\n")
f.write(sql+"\n")
f.write(time.strftime('%m-%d %H:%M:%S',time.localtime(time.time())))
f.close()
开发者ID:CharlesZhong,项目名称:CnkiProject,代码行数:11,代码来源:CnkiParser.py
示例19: insertPaper
def insertPaper(self,paper):
sql = "insert into Paper(Expert_ID,Paper_ID,Paper_Title,Paper_Authorslist,Paper_Url,Paper_Origin,Paper_Pubtime,Paper_Database,Paper_Citation) values('%s','%s','%s','%s','%s','%s','%s','%s','%s')" %(paper.expertID,paper.paperID,paper.title,paper.authorsList,paper.url,paper.origin,paper.pubtime,paper.database,paper.citation)
try:
#print sql
self.cursor.execute(sql)
except Exception, e:
f = open("PaperError.log","a")
f.write(str(e)+"\n")
f.write(sql+"\n")
f.write(time.strftime('%m-%d %H:%M:%S',time.localtime(time.time())))
f.close()
开发者ID:CharlesZhong,项目名称:CnkiProject,代码行数:12,代码来源:CnkiParser.py
示例20: procautoflush
def procautoflush(self):
view=self.view
edit=self.edit
curtime=time.strftime('%Y/%m/%d %H:%M:%S',time.localtime(time.time()))
sel=view.sel()[0]
reg=r"^>{3}[^>][\r\n\S\s]*?[^<]<{3}\d{4}/\d{2}/\d{2}\s\d{2}:\d{2}:\d{2}"
reg_bb=view.find(reg,0)
while not reg_bb.empty():
if reg_bb.begin()<sel.begin() and reg_bb.end()>sel.end():
treg=sublime.Region(reg_bb.end()-19,reg_bb.end())
view.replace(edit,treg,curtime)
reg_bb=view.find(reg,reg_bb.end())
开发者ID:Firef0x,项目名称:SublimeTextConfig,代码行数:12,代码来源:auto_file.py
注:本文中的time.time.strftime函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论