本文整理汇总了Python中lib.db.DB.delete_backup方法的典型用法代码示例。如果您正苦于以下问题:Python DB.delete_backup方法的具体用法?Python DB.delete_backup怎么用?Python DB.delete_backup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.db.DB
的用法示例。
在下文中一共展示了DB.delete_backup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BackupPanel
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import delete_backup [as 别名]
#.........这里部分代码省略.........
self.nbBackup.SetSelection(0)
def delete(self, name):
# Lets get some statistics
runs = self.db.runs(backupname=name)
num_runs = len(runs)
size = 0
for run in runs:
size += run.size
if num_runs > 0:
msg = _("Backup '{backup}' has {numruns} runs stored, " \
"totalling {size} of remote data.\n" \
"Are you sure you want to delete the backup definition?\n" \
"(hint - its usually better to just deactivate the backup)").format(\
backup=name, numruns=num_runs, size=utils.readable_form(size))
mbox = OptionDialog(self, msg, _("Delete Backup Definition"),
_("Also delete all backup data stored remotely\nNote that this cannot be undone."))
if mbox.ShowModal() != wx.ID_OK:
return
delete_offsite_data = mbox.chkOption.GetValue()
else:
msg = _("Backup '{backup}' has never run. Are you " \
"sure you want to delete the backup definition?").format(backup=name)
if dlg.OkCancel(self, msg, _("Confirm Delete")) != wx.ID_OK:
return
delete_offsite_data = False
with ProgressDialog(self, _("Deleting"),
_("Deleting backup %s%s.\nPlease wait...") %
(name, " and all offsite data" if delete_offsite_data else "")):
self.delete_backup(name, delete_offsite_data)
import time
time.sleep(3)
self.clear()
self.state = ViewState
app.broadcast_update()
def show(self, name):
try:
backup = self.config.backups[name]
self.state = ViewState
self.show_backup(backup)
except Exception as e:
# Missing backup!
dlg.Warn(self, _("The backup '{backup}' seems to be corrupt. {error}").format(backup=name, error=str(e)))
# self.update_backup_list()
# self.state = ViewState
# self.clear()
def show_backup(self, b):
# General Information
self.txtName.SetValue(b.name)
self.lblName.SetLabel(b.name)
self.chkActive.SetValue(b.active)
# Folder Information
self.txtFolders.Clear()
self.txtFolders.AppendText("\n".join(b.include_folders))
示例2: ConfigPanel
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import delete_backup [as 别名]
#.........这里部分代码省略.........
size = 0
for run in runs:
size += run.size
# Check with the user.
msg = _("You current have {numruns} backup runs stored, " \
"totalling {size} of remote data.\n" \
"Changing the Master Password means old encrypted backups cannot be used.\n" \
"Note that they can be kept for disaster recovery if needed,\n" \
"but we suggest you simply start fresh.").format(\
numruns=num_runs, size=utils.readable_form(size))
mbox = OptionDialog(self, msg, _("Delete Backup Runs"),
_("Also delete all encrypted backup data stored remotely."),
default=True)
if mbox.ShowModal() != wx.ID_OK:
return
delete_offsite_data = mbox.chkOption.GetValue()
# TODO skip if no runs
# We keep track of all errors
errors = ""
with ProgressDialog(self, _("Deleting"), _("Deleting old encrypted backup data.\nPlease wait...")):
for backup in self.config.backups.itervalues():
# If its encrypted
if backup.encrypt:
# If the option set - delete all offline data at the store
if delete_offsite_data:
try:
# Get the list of unique stores used by runs of this backup
runs = self.db.runs(backup.name)
stores = set([r.store for r in runs])
# Get the store and delete all data.
for storename in stores:
store = self.config.storage[storename].copy()
store.delete_backup_data(backup.name)
except Exception as e:
errors += "\nDelete offline data for %s failed: %s" % (backup.name, str(e))
# Now delete the database records of the run abd backup
try:
self.db.delete_backup(backup.name)
except Exception as e:
errors += "\nDelete local backup information for %s failed: " % (backup.name, str(e))
if len(errors) > 0:
dlg.Error(self, errors)
if not pwd:
self.config.data_passphrase = None
app.show_message('Password cleared')
else:
self.config.data_passphrase = pwd
app.show_message('Password set')
self.config.save()
# Now delete all the backups and offsite data.
######################################################################
#
# Save and Load
#
######################################################################
def update_state(self):
if self.state == ViewState:
self.lblName.Show(True)
self.txtName.Show(False)