本文整理汇总了Python中sync.Sync.prep_lists方法的典型用法代码示例。如果您正苦于以下问题:Python Sync.prep_lists方法的具体用法?Python Sync.prep_lists怎么用?Python Sync.prep_lists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sync.Sync
的用法示例。
在下文中一共展示了Sync.prep_lists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: op_sync
# 需要导入模块: from sync import Sync [as 别名]
# 或者: from sync.Sync import prep_lists [as 别名]
def op_sync (self):
conf = self.get_config()
pname = self._load_profile()
sync = Sync(conf, pname, self.get_db(), dr=self.is_dry_run())
if self.is_dry_run():
sync.prep_lists(self.get_sync_dir())
else:
try:
startt = conf.get_curr_time()
result = sync.sync(self.get_sync_dir())
if result:
conf.set_last_sync_start(pname, val=startt)
conf.set_last_sync_stop(pname)
logging.info('Updating item inventory...')
sync.save_item_lists()
logging.info('Updating item inventory...done')
else:
logging.info('timestamps not reset for profile %s due to '
'errors (previously identified).', pname)
except Exception, e:
logging.critical('Exception (%s) while syncing profile %s',
str(e), pname)
logging.critical(traceback.format_exc())
return False
示例2: op_sync
# 需要导入模块: from sync import Sync [as 别名]
# 或者: from sync.Sync import prep_lists [as 别名]
def op_sync (self):
conf = self.get_config()
pname = self._load_profile()
startt_old = conf.get_last_sync_start(pname)
stopt_old = conf.get_last_sync_stop(pname)
if self.is_sync_all():
# This is the case the user wants to force a sync ignoring the
# earlier sync states. This is useful when ASynK code changes -
# and let's say we add support for synching a enw field, or some
# such.
#
# This works by briefly resetting the last sync start and stop
# times to fool the system. If the user is doing a dry run, we
# will restore his earlier times dutifully.
if self.is_dry_run():
logging.debug('Temporarily resetting last sync times...')
conf.set_last_sync_start(pname, val=utils.time_start)
conf.set_last_sync_stop(pname, val=utils.time_start)
sync = Sync(conf, pname, [x.get_db() for x in self.get_colls()],
dr=self.is_dry_run())
if self.is_dry_run():
sync.prep_lists(self.get_sync_dir())
# Since it is only a dry run, resetting to the timestamps to the
# real older sync is sort of called for.
conf.set_last_sync_start(pname, val=startt_old)
conf.set_last_sync_stop(pname, val=stopt_old)
logging.debug('Reset last sync timestamps to real values')
else:
try:
startt = conf.get_curr_time()
result = sync.sync(self.get_sync_dir())
if result:
conf.set_last_sync_start(pname, val=startt)
conf.set_last_sync_stop(pname)
logging.info('Updating item inventory...')
sync.save_item_lists()
logging.info('Updating item inventory...done')
else:
logging.info('timestamps not reset for profile %s due to '
'errors (previously identified).', pname)
except Exception, e:
logging.critical('Exception (%s) while syncing profile %s',
str(e), pname)
logging.critical(traceback.format_exc())
return False