本文整理汇总了Python中lib.db.DB.update_run_status方法的典型用法代码示例。如果您正苦于以下问题:Python DB.update_run_status方法的具体用法?Python DB.update_run_status怎么用?Python DB.update_run_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.db.DB
的用法示例。
在下文中一共展示了DB.update_run_status方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wiz_execute
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import update_run_status [as 别名]
def wiz_execute(wiz):
db = DB()
config = Config.get_config()
backups = config.backups.keys()
backups.sort()
for name in backups:
if wiz.fields[name].value:
# Get the backup object and store
backup = config.backups[name]
store = config.storage[backup.store].copy()
# For each run on the store
with ProgressDialog(wiz, _("Connecting"), _("Connecting to the store.\nPlease wait...")):
store.connect()
prog_dlg = ProgressDialog(wiz, _("Loading"), _("Retrieving data from store.\nPlease wait..."))
prog_dlg.Show()
try:
try:
runs = store.list(backup.name)
except:
# If it fails, there were no backup runs
runs = []
runs.sort()
for run in runs:
(date, type) = run.split(" ")
date = datetime.strptime(date, const.DateTimeFormat)
db.start_run(backup.name, store.name, type, date)
db.save_message(_("Database rebuild started"))
try:
store_size, _file_sizes, nfiles, nfolders = recover_run(config, db, backup, store, run)
db.save_message(_("Database rebuild complete"))
db.update_run_stats(store_size, nfiles, nfolders, backup.include_packages, "")
db.update_run_status(const.StatusSuccess)
except Exception as e:
msg = _("Database rebuild failed. {error}").format(error=str(e))
db.save_message(msg)
db.update_run_status(const.StatusFailed)
dlg.Warn(wiz, msg, _("Error"))
return
finally:
prog_dlg.Destroy()
store.disconnect()
wiz.parent.force_rebuild()
# Now tell app about change.
app.broadcast_update()
dlg.Info(wiz, _("Your backup files database has been rebuilt.\nYou can now view your file and backup history."), _("Rebuild"))
示例2: Run
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import update_run_status [as 别名]
class Run():
def __init__(self, name, type, options):
'''
Prepare to run a backup event
@param name: name of the backup
@param type: type (Full/Incr)
@param type: dry_run
If dry_run is True, then we will print the files we *would have* backed
up to stdout.
'''
self.type = type
self.dry_run = options.dry_run
self.options = options
self.config = Config.get_config()
try:
self.backup = self.config.backups[name]
except:
raise Exception(_("Backup is missing or corrupt. Please reconfigure backup."))
try:
# Get a fresh store (a copy of the config version
self.store = self.config.storage[self.backup.store].copy()
except:
raise Exception(_("Storage definition is missing. Please reconfigure backup."))
self.db = DB()
self.start_time = None
self.nfiles = None
self.nfolders = None
self.bytes = None
self.run_id = None
self.backup_folder = None
# Make sure there are no other backups running of this name
self.lock = locking.InterProcessLock(name="Vault-%s" % self.backup.name)
# Build a quick file exclusion list, to speed up exclusion checking
self.excl_ext = self.build_excl_exts()
log.debug("Exclusion List:", ",".join(self.excl_ext))
def run(self):
'''
Execute the backup
'''
try:
self.lock.acquire()
except:
msg = _("Backup '%s' is already running. New backup run cannot start") \
% (self.backup.name)
if not self.dry_run:
# Since this is a real backup, we create the run, write to the log and fail immediately.
self.db.start_run(self.backup.name, self.backup.store, self.type, datetime.now())
self.db.save_message(msg)
self.db.update_run_status(const.StatusFailed)
else:
# We dont need to do anything for a dry run. The message will
# be returned to the user.
pass
raise Exception(msg)
# We have the lock now...
try:
self.orig_type = self.type
self.check_old_backups()
self.do_backup()
finally:
self.lock.release()
def check_old_backups(self):
'''
We have got the lock, but if there was a crash, there may be a "running"
state backup left behind. Note that we *know* its not running because
the lock is gone.
Check for it and fail it if there is.
'''
log.debug("Checking for dead backups")
runs = self.db.runs(self.backup.name)
runs = [run for run in runs if run.status == const.StatusRunning]
# It looks like there is a run that is still running.
for run in runs:
log.warn("A prior run crashed. Cleaning up %s/%s" % (run.name, run.start_time_str))
# Get the store
log.debug("Attempting to delete remote run data")
try:
self.store.delete_run_data(run)
except:
pass
# Delete the entries in the database (but not the failed run itself)
# This means the messages will persist, so we can see the usage.
log.debug("Attempting to delete DB run data")
self.db.delete_run_versions(self.run_id)
# Update the status
#.........这里部分代码省略.........