- if not extracted:
- self.set_gui('task', _("Tor Browser Launcher doesn't understand the file format of {0}".format(self.common.paths['tarball_file'])), ['start_over'], False)
- self.clear_ui()
- self.build_ui()
- return
-
- # installation is finished, so save installed_version
- self.common.settings['installed_version'] = self.common.settings['latest_version']
- self.common.save_settings()
-
- self.run_task()
-
- def run(self, run_next_task=True):
- # play modem sound?
- if self.common.settings['modem_sound']:
- def play_modem_sound():
- try:
- import pygame
- pygame.mixer.init()
- sound = pygame.mixer.Sound(self.common.paths['modem_sound'])
- sound.play()
- time.sleep(10)
- except ImportError:
- md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, _("The python-pygame package is missing, the modem sound is unavailable."))
- md.set_position(gtk.WIN_POS_CENTER)
- md.run()
- md.destroy()
-
- t = threading.Thread(target=play_modem_sound)
- t.start()
-
- # hide the TBL window (#151)
- if hasattr(self, 'window'):
- self.window.hide()
- while gtk.events_pending():
- gtk.main_iteration_do(True)
-
- # run Tor Browser
- subprocess.call([self.common.paths['tbb']['start']], cwd=self.common.paths['tbb']['dir_tbb'])
-
- 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() is None:
- time.sleep(0.01)
- self.progressbar.pulse()
- self.refresh_gtk()
-
- # 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', 'verify', 'extract', 'run']
- self.gui_task_i = 0
- self.start(None)
-
- # refresh gtk
- def refresh_gtk(self):
- while gtk.events_pending():
- gtk.main_iteration(False)
-
- # exit
- def delete_event(self, widget, event, data=None):
- return False
-
- def destroy(self, widget, data=None):
- if hasattr(self, 'file_download'):
- self.file_download.close()
- if hasattr(self, 'current_download_path'):
- os.remove(self.current_download_path)
- delattr(self, 'current_download_path')
- delattr(self, 'current_download_url')
- if reactor.running:
- reactor.stop()