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


Python DB.get_fs方法代码示例

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


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

示例1: RunDetailsWindow

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

#.........这里部分代码省略.........
##################################################################
#
#    Utilities
#
##################################################################

    def load_run_details(self):
        #(run_id=3, name=u'test', type=1, start_time=u'2010-12-28T15:09:39.455313', hash=u'6da92e0e7f25d003bfcc2cc7d845868fe6a433e1c0fe349300659fc86c8f66ba', size=59764, nfiles=0, status=u'Succeeded')
        self.lstDetails.InsertColumn(0, _("Name"))
        self.lstDetails.InsertColumn(1, _("Value"))

        self.lstDetails.Append([_("Backup Name"), self.run.name])

        self.lstDetails.Append([_("Run Date"), self.run.start_time_str])
        self.lstDetails.Append([_("Run Type"), self.run.type])
        self.lstDetails.Append([_("Status"), self.run.status])
        self.lstDetails.Append([_("Files Backed Up"), str(self.run.nfiles)])
        self.lstDetails.Append([_("Folders Backed Up"), str(self.run.nfolders)])
        self.lstDetails.Append([_("Installed Software List"), _("Included") if self.run.packages else _("Not included")])
        self.lstDetails.Append([_("Total Size"), utils.readable_form(self.run.size)])
        self.lstDetails.Append([_("Hash"), self.run.hash])

        self.lstDetails.SetColumnWidth(0, wx.LIST_AUTOSIZE)
        self.lstDetails.SetColumnWidth(1, wx.LIST_AUTOSIZE)


    def load_files(self, limit):
        with ProgressDialog(self, _("Loading"), _("Loading run files.\nPlease wait...")):
            self.lstFiles.DeleteAllColumns()
            self.lstFiles.DeleteAllItems()

            self.lstFiles.InsertColumn(0, _("Path"))
            self.lstFiles.InsertColumn(1, _("Size"))
            self.lstFiles.InsertColumn(2, _("Mod Time"))

            self.lstFiles.Freeze()
            try:
                files = self.db.run_contents(self.run.run_id, limit)
                for file in files:
                    wx.Yield()
                    if file.type == "F":
                        size = utils.readable_form(file.size)
                        mod_time = file.mod_time
                    elif file.type == 'D':
                        size = _("Folder")
                        mod_time = file.mod_time
                    elif file.type == 'X':
                        size = _("(deleted)")
                        mod_time = ""
                    else:
                        size = "ERROR: Bad type"
                    path = os.path.join(self.get_path(file.parent_id), file.name)
                    item = (utils.display_escape(path), size, mod_time)
                    self.lstFiles.Append(item)
                self.lstFiles.SetColumnWidth(0, wx.LIST_AUTOSIZE)
                self.lstFiles.SetColumnWidth(1, wx.LIST_AUTOSIZE)
                self.lstFiles.SetColumnWidth(2, wx.LIST_AUTOSIZE)
            finally:
                self.lstFiles.Thaw()

            if self.lstFiles.GetItemCount() < limit:
                #    There probably aren't that many files.
                self.pnlAllFiles.Hide()
                self.pnlFiles.Fit()


    def load_messages(self):
        self.lstMessages.InsertColumn(0, _("Time"))
        self.lstMessages.InsertColumn(1, _("Message"))


        messages = self.db.run_messages(self.run.run_id)
        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 get_path(self, fs_id):
        if fs_id in self.paths:
            return self.paths[fs_id]

        if fs_id == 0:
            return "/"

        #    Get THIS node
        fs = self.db.get_fs(fs_id)
        path = os.path.join(self.get_path(fs.parent_id), fs.name)
        self.paths[fs.fs_id] = path
        return path

    def get_paths(self, files):
        #    For each file, we need to calculate the full path.
        #    That requires getting paths for any path that we dont have yet.
        paths = {}
        for file in files:
            parent_id = file.parent_id
            #    Do we know this parent_id yet?
            file.path = os.path.join(self.get_path(paths, parent_id), file.name)
开发者ID:,项目名称:,代码行数:104,代码来源:


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