当前位置: 首页>>代码示例>>Python>>正文


Python DB.store_usages方法代码示例

本文整理汇总了Python中lib.db.DB.store_usages方法的典型用法代码示例。如果您正苦于以下问题:Python DB.store_usages方法的具体用法?Python DB.store_usages怎么用?Python DB.store_usages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.db.DB的用法示例。


在下文中一共展示了DB.store_usages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OverviewPanel

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import store_usages [as 别名]

#.........这里部分代码省略.........
                            weeks = timesince.days // 7
                            messages.append(_("Backup {backup} should run weekly, but has not run in {weeks} week(s)").format(
                                            backup=backup.name, weeks=weeks))
    
                            state = max(state, const.SystemStateWarn)
        #    If there are no active backups - that too is a warning.
        if len([backup for backup in self.config.backups.itervalues() if backup.active]) == 0:
            state = max(state, const.SystemStateWarn)
            messages.append(_("There are no active backups, so nothing will be backed up"))
        return (state, messages)

    def update_details(self):
        '''
        Update backup detail display.
        '''
        if len(self.config.backups) == 0:
            self.lstBackups.Hide()
            self.lblNoBackups.Show()
        else:
            self.lblNoBackups.Hide()
            self.lstBackups.Show()
            self.lstBackups.DeleteAllColumns()
            self.lstBackups.DeleteAllItems()
            self.lstBackups.InsertColumn(0, _("Name"))
            self.lstBackups.InsertColumn(1, _("State"))
            self.lstBackups.InsertColumn(2, _("Last Run"))
            runs = self.db.run_states()
            for bname, backup in self.config.backups.iteritems():
                active = _("Active") if backup.active else _("Inactive")
                if bname in runs:
                    run = runs[bname]
                    if run.status == const.StatusFailed:
                        msg = ("Ran %s, failed") % run.start_time_str
                    elif run.status == const.StatusRunning:
                        msg = _("Running now, started {time}").format(time=run.start_time_str)
                    else:
                        msg = _("Ran {time}, saved {files} files, compressed size {size}").format(
                            time=run.start_time_str, files=run.nfiles, size=utils.readable_form(run.size))
#                    line = "%s: last run %s, backed up %d files, total size %s" % (bname, run.start_time_str, run.nfiles, utils.readable_form(run.size))
                else:
                    msg = _("Never run")
                self.lstBackups.Append([bname, active, msg])

            self.lstBackups.SetColumnWidth(0, wx.LIST_AUTOSIZE)
            self.lstBackups.SetColumnWidth(1, wx.LIST_AUTOSIZE)
            self.lstBackups.SetColumnWidth(2, wx.LIST_AUTOSIZE)

            return

    def update_stores(self):
        '''
        Update store detail display.
        
        Note that the size is gleaned from the sum of all runs, 
        PLUS (because running runs have size 0)
            the sum of all files in a running run.
        '''
        log.trace("update_stores")
        if len(self.config.storage) == 0:
            self.lstStores.Hide()
        else:
            self.lblNoStores.Hide()
            self.lstStores.DeleteAllColumns()
            self.lstStores.DeleteAllItems()
            self.lstStores.InsertColumn(0, _("Name"))
            self.lstStores.InsertColumn(1, _("Space"))
            self.lstStores.InsertColumn(2, _("Used"))

            #    Includes runs that have completed.
            uses = self.db.store_usages()
            
            log.debug("Update Stores: uses=", uses)
            
            for sname, store in self.config.storage.iteritems():
                if sname in uses:
                    used = uses[sname].size
                else:
                    used = 0

                self.lstStores.Append([store.name,
                                       _("Unlimited") if not store.auto_manage else store.limit,
                                       utils.readable_form(used)])

            self.lstStores.SetColumnWidth(0, wx.LIST_AUTOSIZE)
            self.lstStores.SetColumnWidth(1, wx.LIST_AUTOSIZE)
            self.lstStores.SetColumnWidth(2, wx.LIST_AUTOSIZE)
        log.trace("completed update_stores")


    def onHistory(self, event):
        self.hist_window = HistoryWindow(self)

    def onRefresh(self, event):
        self.update_data()

    def onSetupStore(self, event):
        do_store_wizard(self)

    def onSetupBackup(self, event):
        do_backup_wizard(self)
开发者ID:,项目名称:,代码行数:104,代码来源:


注:本文中的lib.db.DB.store_usages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。