本文整理汇总了Python中utils.utils.Utils.timestamp_to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Utils.timestamp_to_string方法的具体用法?Python Utils.timestamp_to_string怎么用?Python Utils.timestamp_to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.utils.Utils
的用法示例。
在下文中一共展示了Utils.timestamp_to_string方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from utils.utils import Utils [as 别名]
# 或者: from utils.utils.Utils import timestamp_to_string [as 别名]
def run(self):
print("Running...")
os.system('ls -i -t ' + self._cfg['dir_archive'] +'/* | cut -d\' \' -f2 | tail -n+1 | xargs rm -f')
data_old = JSONAdapter.load(self._cfg['dir_in'], self._cfg['serial_file'])
if data_old is not None:
data_file_name_new = data_old[0] + '_' + self._cfg['serial_file']
Utils.rename_file(self._cfg['dir_in'], self._cfg['dir_archive'], \
self._cfg['serial_file'], data_file_name_new)
else:
data_old = []
if Utils.is_internet_up() is True:
urls = self._cfg['urls_to_check']
data_new = []
data_new.insert(0, Utils.timestamp_to_string(time.time()))
thread_id = 0
threads = []
display = Display(visible=0, size=(1024, 768))
display.start()
for url in urls:
thread_id += 1
alivechecker_thread = AliveChecker(thread_id, self._cfg, url)
threads.append(alivechecker_thread)
alivechecker_thread.start()
# Waiting for all threads to complete
for thread in threads:
thread.join()
display.stop()
for thread in threads:
data_new.append(thread.data)
logging.debug('%s\n' % (thread.log))
thread.browser.quit()
if len(data_new) > 0:
JSONAdapter.save(data_new, self._cfg['dir_in'], self._cfg['serial_file'])
data_all = []
if len(data_old) > 0:
data_all.append(data_old)
data_all.append(data_new)
JSONAdapter.save(data_all, self._cfg['dir_out'], self._cfg['serial_file'])
state = self._evaluator.run(data_all)
logging.debug('Final state: %s' % (state))
if self._emailnotifiers and state != '':
EmailNotifiers.notify(state)
else:
logging.debug('Empty data')
else:
logging.error('Internet is definitely down!')
sys.exit(2)
print("Done...")