+ def verify(self):
+ # initialize the progress bar
+ self.progressbar.set_fraction(0)
+ self.progressbar.set_text('Verifying Signature')
+ self.progressbar.show()
+
+ p = subprocess.Popen([self.paths['file']['verify'], self.paths['dir']['gpg'], self.paths['file']['tarball_sig']], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.pulse_until_process_exits(p)
+
+ output = p.stdout.read()
+
+ if 'Good signature' in output:
+ self.run_task()
+ else:
+ self.progressbar.hide()
+ self.label.set_text("SIGNATURE VERIFICATION FAILED!\n\nYou might be under attack, or there might just be a networking problem. Click Start try the download again.")
+ self.gui_tasks = ['start_over']
+ self.gui_task_i = 0
+ self.start_button.set_sensitive(True)
+
+ def extract(self):
+ # initialize the progress bar
+ self.progressbar.set_fraction(0)
+ self.progressbar.set_text('Installing')
+ self.progressbar.show()
+
+ p = subprocess.Popen(['tar', '-xf', self.paths['file']['tarball'], '-C', self.paths['dir']['tbb']], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ self.pulse_until_process_exits(p)
+
+ self.run_task()
+
+ def run(self, run_next_task = True):
+ subprocess.Popen([self.paths['file']['start']])
+ if run_next_task:
+ self.run_task()
+
+ # make the progress bar pulse until process p (a Popen object) finishes
+ def pulse_until_process_exits(self, p):
+ while p.poll() == None:
+ time.sleep(0.01)
+ self.progressbar.pulse()
+ # redraw gtk
+ while gtk.events_pending():
+ gtk.main_iteration(False)
+
+ # start over and download TBB again
+ def start_over(self):
+ self.label.set_text("Downloading Tor Browser Bundle over again.")
+ self.gui_tasks = ['download_tarball', 'download_tarball_sig', 'verify', 'extract', 'run']
+ self.gui_task_i = 0
+ self.start(None)
+