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


Python DB.runs方法代码示例

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


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

示例1: Verify

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import runs [as 别名]
class Verify():
    def __init__(self, backup_name, run_date):
        '''
        Verify a run to ensure it is valid
        
        '''
        self.config = Config.get_config()
        self.backup = self.config.backups[backup_name]
        self.store = self.config.storage[self.backup.store].copy()

        self.db = DB()

        #    Find the run
        runs = self.db.runs(self.backup.name, run_date)
        if len(runs) == 0:
            raise Exception(_("Verify failed: Backup run does not exist"))
        self.vrun = runs[0]


    def run(self):

        self.test_store()
        #    Get config and packages
        self.fetch_config()

        #    We only check the data if there is actually something stored there.
        if self.vrun.nfiles == 0 and self.vrun.nfolders == 0:
            return True

        self.prepare_input(self.vrun, self.backup, self.store)
        try:
            #    Only check for tar data if there are files backed up
            #    Otherwise the tar will simply return an error
            tarinfo = self.tarfile.next()
            while tarinfo:
                tarinfo = self.tarfile.next()

        finally:
            self.close_input(self.backup)

        store_size, store_hash, = self.store_thread.get_hash()
        run_hash = self.vrun.hash
        run_size = self.vrun.size
        if store_size == run_size and store_hash == run_hash:
            return True
#        print(store_size, store_hash, run_size, run_hash)
        raise Exception(_("Verify failed - Run data is corrupt"))

    def test_store(self):
        store = self.config.storage[self.store.name].copy()
        store.connect()
        try:
            store.test()
        finally:
            store.disconnect()

    def fetch_config(self):
        store = self.config.storage[self.store.name].copy()
        store.connect()
        try:
            encrypted = False
            config = os.path.join(self.vrun.folder, const.ConfigName)
            if not store.exists(config):
                encrypted = True
                config = config + const.EncryptionSuffix
                if not store.exists(config):
                    raise Exception(_("Configuration file missing. Bad run"))

            store.get(config, os.path.join(tempfile.gettempdir(), "__vault__tmp__"))
            os.remove(os.path.join(tempfile.gettempdir(), "__vault__tmp__"))
            if self.backup.include_packages:
                packages = os.path.join(self.vrun.folder, const.PackageFile)
                if encrypted:
                    packages = packages + const.EncryptionSuffix
                store.get(packages, os.path.join(tempfile.gettempdir(), "__vault__tmp__"))
                os.remove(os.path.join(tempfile.gettempdir(), "__vault__tmp__"))
        finally:
            store.disconnect()

    def prepare_input(self, run, backup, store):
        '''
        Open the tar file.
        Connect the output of the tar to either:
        a) the storage handler
        b) to encryption (openssl), THEN the storage handler
        
        '''
        log.trace("Setting up input processes")

        #    Set up the encryptor (use TEE for now)
        self.crypt_proc = None
        if backup.encrypt:
            log.debug("Creating crypt objects")
            self.crypto = cryptor.DecryptStream(self.config.data_passphrase)
        else:
            self.crypto = cryptor.Buffer()

        #    Set up the storage handler
        log.debug("Starting storage thread")

#.........这里部分代码省略.........
开发者ID:tussock,项目名称:Vault,代码行数:103,代码来源:verify.py

示例2: ConfigPanel

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

#.........这里部分代码省略.........
        if self.pwd_hidden:
            self.txtMasterPassword.SetWindowStyle(wx.NORMAL)
            self.pwd_hidden = False
            self.btnHidePassword.SetLabel("Hide")
        else:
            self.txtMasterPassword.SetWindowStyle(wx.TE_PASSWORD)
            self.pwd_hidden = True
            self.btnHidePassword.SetLabel("Show")

    def show_security(self):
        if not self.config.data_passphrase:
            self.txtMasterPassword.SetValue("")
        else:
            self.txtMasterPassword.SetValue(self.config.data_passphrase)
        self.onMasterPasswordChar(None)

    def onMasterPasswordChar(self, event):
        """Recalculate entropy any time the password changes."""
        pwd = self.txtMasterPassword.GetValue()
        e = int(cryptor.entropy(pwd))
        if e < 0:
            e = 0
        if e > 100:
            e = 100
        self.strength.SetValue(e)
        if event:
            event.Skip()

    def onSavePassword(self, event):
        pwd = self.txtMasterPassword.GetValue()
        if pwd != self.config.data_passphrase:
            #    Password has changed. Do we have any stored backups? 
            #    If so, they should be deleted.
            runs = self.db.runs()
            num_runs = len(runs)
            if num_runs > 0:
                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]) 
开发者ID:tussock,项目名称:Vault,代码行数:70,代码来源:configpanel.py

示例3: BackupPanel

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

#.........这里部分代码省略.........
            self.txtFolders.Clear()
            self.txtFolders.AppendText("\n".join(folders))

    def onBackupSchedule(self, event):
        if self.radSchedAdvanced.GetValue():
            self.pnlAdvanced.Show()
        else:
            self.pnlAdvanced.Hide()


######################################################################
#
#        Save and Load
#
######################################################################
    def update_state(self):
        if self.state == ViewState:
            self.lblName.Show(True)
            self.txtName.Show(False)
        if self.state == NewState:
            self.lblName.Show(False)
            self.txtName.Show(True)
        self.onBackupSchedule(None)
        self.Fit()
        self.Refresh()

    def clear(self):
        b = Backup(EmptyName)
        self.show_backup(b)
        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()
开发者ID:tussock,项目名称:Vault,代码行数:70,代码来源:backuppanel.py

示例4: RestorePanel

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import runs [as 别名]
class RestorePanel(gui.RestorePanel):
    '''
    classdocs
    '''


    def __init__(self, parent):
        '''
        Constructor
        '''
        log.info("***RestorePanel.init")

        gui.RestorePanel.__init__(self, parent)
        self.db = DB()
        self.config = Config.get_config()
        self.images = wx.ImageList(16, 16)
        self.images.Add(
                        wx.Bitmap(os.path.join(const.PixmapDir, "folder.png"), 
                                  wx.BITMAP_TYPE_PNG)
                        )
        self.images.Add(
                        wx.Bitmap(os.path.join(const.PixmapDir, "document.png"), 
                                  wx.BITMAP_TYPE_PNG)
                        )
        self.fs_tree.SetImageList(self.images)
        #    Looks better if this is blank.
        self.set_selected_file("")
        self.force_rebuild()

        self.image = wx.Bitmap(os.path.join(const.PixmapDir, "review.png"))
        self.title = _("Restore")

        #    Ensure the right page is showing
        self.nb_restore.SetSelection(0)
        log.trace("Done RestorePanel.init")

    def prepare_static_data(self):
        #    Load all runs for the date slider
        self.runs = self.db.runs()

        self.date_slider.SetMin(0)
        log.debug("Date Slider: %d runs" % len(self.runs))
        if len(self.runs) in [0, 1]:
            #    Cannot set a slider with 0 or 1 positions. So disable it.
            self.date_slider.Enable(False)
            self.date_slider.SetMax(1)
            self.date_slider.SetValue(0)
        else:
            self.date_slider.SetMax(len(self.runs) - 1)
            self.date_slider.SetValue(len(self.runs) - 1)
            self.date_slider.Enable(True)

        self.cboBackup.Clear()
        self.cboBackup.AppendItems([name for name in self.config.backups.iterkeys()])
        if self.cboBackup.Count > 0:
            self.cboBackup.SetSelection(0)

    def force_rebuild(self):
        log.debug("Forcing complete rebuild")
        self.displayed_run = None
        self.prepare_static_data()
        #    Prepare the tree
        self.fs_tree.DeleteAllItems()
        self.root_node = self.fs_tree.AddRoot(text="/", image=0)
        self.fs_tree.SetItemPyData(self.root_node, node_info(0, 0, "D", False, "/"))
        self.expand_node(self.root_node)
        self.onSliderScroll(None)
        self.pnlRestore.Layout()

    def update_data(self):
        # TODO! This could be dangerously time consuming!
        self.prepare_static_data()
        self.onSliderScroll(None)
        self.rebuild_tree()
        self.pnlRestore.Layout()

    def get_current_run(self):
        if len(self.runs) == 0:
            return None
        if len(self.runs) == 1:
            return self.runs[0]

        idx = self.date_slider.GetValue()
        if idx >= len(self.runs):
            raise Exception("Invalid date slider position")
        return self.runs[idx]

    def expand_node(self, parent_node):
        log.trace("expand_node", parent_node)
        run = self.get_current_run()
        if not run:
            return
        #    Get the folder - which is in data
        parent_info = self.fs_tree.GetItemPyData(parent_node)
        log.debug("expanding node", parent_info)
        if parent_info.expanded:
            log.debug("Already expanded")
            return
        if parent_info.type == "F":
            log.debug("File node (no children)")
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例5: VerifyTestCase

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import runs [as 别名]
class VerifyTestCase(unittest.TestCase):

    def setUp(self):
        self.config = Config.get_config()

        self.db = DB()
        self.db.check_upgrade()
        self.mark_db_ids()

        self.test_folder = tempfile.mkdtemp()
        self.files_folder = os.path.join(self.test_folder, "files")
        self.store_folder = os.path.join(self.test_folder, "store")
        self.restore_folder = os.path.join(self.test_folder, "restore")
        utils.makedirs(self.files_folder)
        utils.makedirs(self.store_folder)
        utils.makedirs(self.restore_folder)

        utils.build_file_structure(self.files_folder, 50 * const.Kilobyte, 500 * const.Kilobyte)

        #    Build a store object (dont save config)
        #    Note the careful size selection - we want backups to overflow the FolderStore.
        self.store = FolderStore("teststore", "2MB", True, self.store_folder)
        self.config.storage[self.store.name] = self.store

        #    Build the backup object (dont save config)
        self.backup = Backup("testbackup")
        self.backup.include_folders = [self.files_folder]
        self.backup.store = self.store.name
        self.backup.notify_msg = False
        self.include_packages = True
        self.config.backups[self.backup.name] = self.backup

        #    build an options object for use with the backup
        self.options = BlankClass()
        self.options.dry_run = False
        self.options.message = False
        self.options.email = False
        self.options.shutdown = False
        self.options.norecurse = False

        self.old_pass = self.config.data_passphrase
        self.config.data_passphrase = "banana"


    def tearDown(self):
        self.config.data_passphrase = self.old_pass
        #    Remove all DB records created during this test
        self.clean_db()
        shutil.rmtree(self.test_folder)
        self.assertFalse(os.path.isdir(self.test_folder))


    def testVerify(self):
        #    Run a full backup
        b = Run("testbackup", const.FullBackup, self.options)
        b.run()

        #    Get the times
        runs = self.db.runs("testbackup")
        run = runs[0]


        v = Verify("testbackup", run.start_time)
        self.assertTrue(v.run())


    def testBadVerify(self):
        #    Run a full backup
        b = Run("testbackup", const.FullBackup, self.options)
        b.run()

        #    Get the times
        runs = self.db.runs("testbackup")
        run = runs[0]

        #    Get the location of the data file from the streamer
        streamer = StreamOut(None, self.store, b.backup_folder)
        datafile = os.path.join(self.store.root, streamer.get_path(0))
        size = os.path.getsize(datafile)
        #    Now corrupt the data file a little
        with open(datafile, "r+b") as f:
            f.seek(size // 2, 0)
            f.write("X")


        v = Verify("testbackup", run.start_time)
        self.assertRaises(Exception, v.run)


    def testBadConfig(self):
        #    Run a full backup
        b = Run("testbackup", const.FullBackup, self.options)
        b.run()

        #    Get the times
        runs = self.db.runs("testbackup")
        run = runs[0]

        #    Delete The Config File
        configfile = os.path.join(run.folder, const.ConfigName)
#.........这里部分代码省略.........
开发者ID:tussock,项目名称:Vault,代码行数:103,代码来源:test_verify.py

示例6: ServerTestCase

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import runs [as 别名]
class ServerTestCase(unittest.TestCase):

    def setUp(self):
        self.config = Config.get_config()
        self.db = DB()
        self.db.check_upgrade()
        self.mark_db_ids()

        self.test_folder = tempfile.mkdtemp()
        self.files_folder = os.path.join(self.test_folder, "files")
        self.store_folder = os.path.join(self.test_folder, "store")
        self.restore_folder = os.path.join(self.test_folder, "restore")
        utils.makedirs(self.files_folder)
        utils.makedirs(self.store_folder)
        utils.makedirs(self.restore_folder)

        utils.build_file_structure(self.files_folder, 50 * const.Kilobyte, 500 * const.Kilobyte)

        #    Build a store object (dont save the config)
        #    Note the careful size selection - we want backups to overflow the FolderStore.
        self.store = FolderStore("teststore", "2MB", True, self.store_folder)
        self.config.storage[self.store.name] = self.store

        #    Build the backup object (dont save config)
        self.backup = Backup("testbackup")
        self.backup.include_folders = [self.files_folder]
        self.backup.store = self.store.name
        self.backup.notify_msg = False
        self.old_pass = self.config.data_passphrase
        self.config.data_passphrase = "goofy"
        self.backup.encrypt = True
        self.config.backups[self.backup.name] = self.backup

        #    build an options object for use with the backup
        self.options = BlankClass()
        self.options.dry_run = False
        self.options.message = False
        self.options.email = False
        self.options.shutdown = False
        self.options.norecurse = False


    def tearDown(self):
        self.config.data_passphrase = self.old_pass
        #    Remove all DB records created during this test
        self.clean_db()
        shutil.rmtree(self.test_folder)
        self.assertFalse(os.path.isdir(self.test_folder))


    def testBackupRestore(self):
        self.backup_restore_compare()

    def testCheckFiles(self):
        self.backup.include_packages = True
        b = Run("testbackup", const.FullBackup, self.options)
        b.run()
        #    Check that all the right files are there.
        runs = self.db.runs(self.backup.name)
        self.assertEqual(len(runs), 1)
        run = runs[0]
        folder = run.folder
        self.assertTrue(self.store.exists(os.path.join(folder, const.PackageFile + const.EncryptionSuffix)))
        self.assertTrue(self.store.exists(os.path.join(folder, const.LOFFile + const.EncryptionSuffix)))
        self.assertTrue(self.store.exists(os.path.join(folder, const.ConfigName + const.EncryptionSuffix)))

        self.assertTrue(self.store.exists)

    def testAutoManagementOfStore1(self):
        #    Run a set of backups that will overload the store. 
        #    The automanaged store should continue to archive old backups as required.
        #    Store space reclaimation happens across all backups (i.e. any run).
        #    We should see older runs from the first backup disappear.
        max_size, dummy, dummy = self.store.limit_details()

        filesize = utils.du(self.backup.include_folders[0])

        #    Lets make sure we are going to do enough backups that
        #    the older ones will be removed.
        RunCount = (max_size // filesize) + 2


        last_start = None
        for cycle in xrange(RunCount):
            if last_start:
                #    Make sure we have ticked to another second since the start of the last backup.
                while datetime.now() - last_start < timedelta(seconds=1):
                    time.sleep(0.01)

            backup = Backup(self.backup.name + str(cycle))
            backup.include_folders = self.backup.include_folders
            backup.store = self.backup.store
            backup.notify_msg = False
            self.config.backups[backup.name] = backup

            #    Run a full backup
            b = Run(backup.name, const.FullBackup, self.options)
            b.run()
            last_start = b.start_time

#.........这里部分代码省略.........
开发者ID:tussock,项目名称:Vault,代码行数:103,代码来源:test_server.py

示例7: Run

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import runs [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
#.........这里部分代码省略.........
开发者ID:tussock,项目名称:Vault,代码行数:103,代码来源:run.py

示例8: HistoryWindow

# 需要导入模块: from lib.db import DB [as 别名]
# 或者: from lib.db.DB import runs [as 别名]
class HistoryWindow(gui.HistoryWindow):
    '''
    classdocs
    '''


    def __init__(self, parent, default_name=None):
        '''
        Constructor
        '''
        gui.HistoryWindow.__init__(self, parent)

        log.trace("Starting up a history panel")
        self.db = DB()
        self.config = Config.get_config()

        self.order = const.ASC
        
        self.update_data(default_name)

#        self.imgList = wx.ImageList(16, 16)
#        self.img_up = self.imgList.Add(wx.Bitmap("images/go-up.png", wx.BITMAP_TYPE_PNG))
#        self.img_down = self.imgList.Add(wx.Bitmap("images/go-down.png", wx.BITMAP_TYPE_PNG))
#        self.lstRuns.SetImageList(self.imgList, wx.IMAGE_LIST_SMALL)

        icon = wx.Icon(os.path.join(const.PixmapDir, "storage.png"), wx.BITMAP_TYPE_ANY)
        self.SetIcon(icon)

#        listmix.ColumnSorterMixin.__init__(self, 7)
#        self.Bind(wx.EVT_LIST_COL_CLICK, self.onColClick, self.lstRuns)

#        self.SortListItems(2, 1)

        #    Ensure the right page is showing
        self.nb_history.SetSelection(0)
        self.Show()


    def update_data(self, default_name = None):
        all = _("***All Backups***")
        if default_name:
            old_sel = default_name
        else:
            old_sel = self.cboBackup.GetStringSelection()
        if not old_sel:
            old_sel = all
        self.cboBackup.Clear()
        self.cboBackup.AppendItems([all])
        self.cboBackup.AppendItems(self.config.backups.keys())
        self.cboBackup.SetStringSelection(old_sel)

        self.update_runs()
        self.update_messages()

    def update_runs(self):
        if self.cboBackup.GetSelection() == 0:
            runs = self.db.runs()
        else:
            backup_name = self.cboBackup.GetStringSelection()
            runs = self.db.runs(backupname=backup_name)
            
        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

#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


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