def on_button_test_clicked(self, button, data=None): ''' Perform a test to find the best mirror and select it afterwards in the treeview ''' self.button_cancel.set_sensitive(True) self.dialog_test.show() self.running = threading.Event() self.running.set() progress_update = threading.Event() pipe = os.popen("dpkg --print-architecture") arch = pipe.read().strip() test_file = "dists/%s/%s/binary-%s/Packages.gz" % \ (self.distro.source_template.name, self.distro.source_template.components[0].name, arch) test = MirrorTest(list(self.distro.source_template.mirror_set.values()), test_file, progress_update, self.running) test.start() # now run the tests in a background thread, and update the UI on each event while self.running.is_set(): while Gtk.events_pending(): Gtk.main_iteration_do(False) # don't spin the CPU until there's something to update; but update the # UI at least every 100 ms progress_update.wait(0.1) if progress_update.is_set(): self.progress.set_text(_("Completed %s of %s tests") % \ (test.progress[0], test.progress[1])) self.progress.set_fraction(test.progress[2]) progress_update.clear() self.dialog_test.hide() self.label_test.set_label("") # Select the mirror in the list or show an error dialog if test.best != None: self.model_sort.foreach(self.select_mirror, test.best) else: dialogs.show_error_dialog(self.dialog, _("No suitable download server was found"), _("Please check your Internet connection."))
def on_button_test_clicked(self, button, data=None): ''' Perform a test to find the best mirror and select it afterwards in the treeview ''' self.button_cancel.set_sensitive(True) self.dialog_test.show() self.running = threading.Event() self.running.set() progress_update = threading.Event() pipe = os.popen("dpkg --print-architecture") arch = pipe.read().strip() test_file = "dists/%s/%s/binary-%s/Packages.gz" % \ (self.distro.source_template.name, self.distro.source_template.components[0].name, arch) test = MirrorTest(self.distro.source_template.mirror_set.values(), test_file, progress_update, self.running) test.start() # now run the tests in a background thread, and update the UI on each event while self.running.is_set(): while Gtk.events_pending(): Gtk.main_iteration_do(False) # don't spin the CPU until there's something to update; but update the # UI at least every 100 ms progress_update.wait(0.1) if progress_update.is_set(): self.progress.set_text(_("Completed %s of %s tests") % \ (test.progress[0], test.progress[1])) self.progress.set_fraction(test.progress[2]) progress_update.clear() self.dialog_test.hide() # Select the mirror in the list or show an error dialog if test.best != None: self.model_sort.foreach(self.select_mirror, test.best) else: dialogs.show_error_dialog(self.dialog, _("No suitable download server was found"), _("Please check your Internet connection."))
def __init__(self, mirrors, test_file, running, dialog, parent): MirrorTest.__init__(self, mirrors, test_file, running) self.dialog = dialog self.parent = parent
def __init__(self, mirrors, test_file, running, dialogue, parent): MirrorTest.__init__(self, mirrors, test_file, running) self.dialogue = dialogue self.parent = parent
def __init__(self, mirrors, test_file, running, progressbar, label): MirrorTest.__init__(self, mirrors, test_file, running) self.progress = progressbar self.label = label
def __init__(self, mirrors, test_file, running, dialog, parent): MirrorTest.__init__(self, mirrors, test_file, None, running) self.dialog = dialog self.parent = parent