本文整理匯總了Python中pywikibot.Timestamp.now方法的典型用法代碼示例。如果您正苦於以下問題:Python Timestamp.now方法的具體用法?Python Timestamp.now怎麽用?Python Timestamp.now使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pywikibot.Timestamp
的用法示例。
在下文中一共展示了Timestamp.now方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: from pywikibot import Timestamp [as 別名]
# 或者: from pywikibot.Timestamp import now [as 別名]
def run(self):
"""Run the bot."""
starttime = time()
rc_listener = site_rc_listener(self.site, timeout=60)
while True:
pywikibot.output(Timestamp.now().strftime(">> %H:%M:%S: "))
self.read_lists()
try:
self.markBlockedusers(self.loadBlockedUsers())
self.contactDefendants(bootmode=self.start)
except pywikibot.EditConflict:
pywikibot.output("Edit conflict found, try again.")
continue # try again and skip waittime
except pywikibot.PageNotSaved:
pywikibot.output("Page not saved, try again.")
continue # try again and skip waittime
# wait for new block entry
print()
now = time()
pywikibot.stopme()
for i, entry in enumerate(rc_listener):
if i % 25 == 0:
print('\r', ' ' * 50, '\rWaiting for events', end='')
if entry['type'] == 'log' and \
entry['log_type'] == 'block' and \
entry['log_action'] in ('block', 'reblock'):
pywikibot.output('\nFound a new blocking event '
'by user "%s" for user "%s"'
% (entry['user'], entry['title']))
break
if entry['type'] == 'edit' and \
not entry['bot'] and \
entry['title'] == self.vmPageName:
pywikibot.output('\nFound a new edit by user "%s"'
% entry['user'])
break
if not entry['bot']:
print('.', end='')
print('\n')
self.optOutListAge += time() - now
# read older entries again after ~4 minutes
if time() - starttime > 250:
starttime = time()
self.reset_timestamp()
self.start = False
self.total = 10