本文整理汇总了Python中lib.db.DB.run_details方法的典型用法代码示例。如果您正苦于以下问题:Python DB.run_details方法的具体用法?Python DB.run_details怎么用?Python DB.run_details使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.db.DB
的用法示例。
在下文中一共展示了DB.run_details方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Run
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import run_details [as 别名]
#.........这里部分代码省略.........
backup=self.backup.name,
type=self.type)
self.db.save_message(msg)
# self.do_verify()
# Messaging...
# If its a dry run, the command line specifies messaging.
# Otherwise both the command line AND backup spec do.
if not self.dry_run:
self.db.update_run_status(const.StatusSuccess)
message = _("Backup {server}/{backup}/{type} completed").format(
server=utils.get_hostname(),
backup=self.backup.name,
type=self.type)
if self.dry_run:
message += " " + _("(Dry Run)")
success = True
if not self.dry_run:
self.db.save_message(message)
except Exception as e:
log.error("Exception in backup. Recording. ", e)
message = _("Backup {server}/{backup}/{type} failed. {error}").format(
server=utils.get_hostname(),
backup=self.backup.name,
type=self.type,
error=str(e))
success = False
if not self.dry_run:
self.db.update_run_status(const.StatusFailed)
# After a failed backup - we must remove the backup data because it
# cannot be trusted.
run = self.db.run_details(self.run_id)
# Delete the remote data
log.debug("Attempting to delete remote run data")
self.store.delete_run_data(run)
# 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)
self.db.save_message(message)
if self.options.message or (self.backup.notify_msg and not self.dry_run):
try:
from lib.dlg import Notify
Notify(const.AppTitle, message)
except Exception as e:
# This one is not really an error... there is probably no-one logged in.
msg = _("Unable to send notification message (no-one logged in)")
if not self.dry_run:
self.db.save_message(message)
log.info(msg)
if self.options.email or (self.backup.notify_email and not self.dry_run):
try:
self.send_email(success, message)
except Exception as e:
msg = _("Unable to email notification message: {error}").format(
error=str(e))
if not self.dry_run:
self.db.save_message(message)
log.error(msg)
if self.options.shutdown or (self.backup.shutdown_after and not self.dry_run):
try:
示例2: HistoryWindow
# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import run_details [as 别名]
#.........这里部分代码省略.........
if self.order == const.ASC:
runs.sort(key=lambda x : x.start_time_str, reverse=False)
self.txtOrder.SetLabel("Order: Oldest First")
else:
runs.sort(key=lambda x : x.start_time_str, reverse=True)
self.txtOrder.SetLabel("Order: Newest First")
self.lstRuns.DeleteAllColumns()
self.lstRuns.DeleteAllItems()
self.lstRuns.InsertColumn(0, _("Name"), wx.LIST_FORMAT_LEFT)
self.lstRuns.InsertColumn(1, _("Type"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(2, _("Time"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(3, _("Status"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(4, _("Files"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(5, _("Folders"), wx.LIST_FORMAT_CENTER)
self.lstRuns.InsertColumn(6, _("Size"), wx.LIST_FORMAT_CENTER)
self.itemDataMap = {}
idx = 0
for run in runs:
row = [run.name, run.type, run.start_time_str, run.status, str(run.nfiles), str(run.nfolders), utils.readable_form(run.size)]
self.lstRuns.Append(row)
self.lstRuns.SetItemData(idx, run.run_id)
self.itemDataMap[idx + 1] = row
idx = idx + 1
self.itemIndexMap = self.itemDataMap.keys()
self.lstRuns.SetColumnWidth(0, 100)
self.lstRuns.SetColumnWidth(1, 50)
self.lstRuns.SetColumnWidth(2, wx.LIST_AUTOSIZE)
self.lstRuns.SetColumnWidth(3, 80)
self.lstRuns.SetColumnWidth(4, 120)
self.lstRuns.SetColumnWidth(5, 100)
self.lstRuns.SetColumnWidth(6, wx.LIST_AUTOSIZE)
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetListCtrl(self):
return self.lstRuns
# Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
def GetSortImages(self):
return (self.img_down, self.img_up)
def onColClick(self, event):
event.Skip()
def update_messages(self):
self.lstMessages.DeleteAllColumns()
self.lstMessages.DeleteAllItems()
self.lstMessages.InsertColumn(0, _("Time"))
self.lstMessages.InsertColumn(1, _("Message"))
if self.cboBackup.GetSelection() == 0:
messages = self.db.messages()
else:
backup_name = self.cboBackup.GetStringSelection()
messages = self.db.backup_messages(backup_name)
if self.order == const.ASC:
messages.sort(reverse=False, key=lambda msg: msg.time)
else:
messages.sort(reverse=True, key=lambda msg: msg.time)
for msg in messages:
item = (msg.time, msg.message)
self.lstMessages.Append(item)
self.lstMessages.SetColumnWidth(0, wx.LIST_AUTOSIZE)
self.lstMessages.SetColumnWidth(1, wx.LIST_AUTOSIZE)
def onBackup(self, event):
self.update_data()
def onRefresh(self, event):
self.update_data()
def onDetails(self, event):
# Get the selected item
sel = self.lstRuns.GetFirstSelected()
if sel == -1:
return
run_id = self.lstRuns.GetItemData(sel)
# Will raise an exception if no run
run = self.db.run_details(run_id)
RunDetailsWindow(self, run)
def onLeftDClick(self, event):
self.onDetails(event)
def onOrder(self, event):
if self.order == const.ASC:
self.order = const.DESC
else:
self.order = const.ASC
self.update_data()