[Pkg-privacy-commits] [torbrowser-launcher] 20/28: If a download results in a 404 and the language is not en-US, try downloading the en-US Tor Browser instead
Ulrike Uhlig
u-guest at moszumanska.debian.org
Sun Jul 10 21:18:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
u-guest pushed a commit to branch debian/sid
in repository torbrowser-launcher.
commit 43a549c17cd6a4ef4c3bb879a900a36e2244d7fe
Author: Micah Lee <micah at micahflee.com>
Date: Fri Jul 8 14:37:31 2016 -0700
If a download results in a 404 and the language is not en-US, try downloading the en-US Tor Browser instead
---
torbrowser_launcher/common.py | 11 ++++++-----
torbrowser_launcher/launcher.py | 18 ++++++++++++++++++
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/torbrowser_launcher/common.py b/torbrowser_launcher/common.py
index 5242eb3..3065503 100644
--- a/torbrowser_launcher/common.py
+++ b/torbrowser_launcher/common.py
@@ -70,10 +70,6 @@ class Common:
self.architecture = 'x86_64' if '64' in platform.architecture()[0] else 'i686'
# figure out the language
- if hasattr(self, 'settings') and self.settings['force_en-US']:
- self.language = 'en-US'
- return
-
available_languages = ['en-US', 'ar', 'de', 'es-ES', 'fa', 'fr', 'it', 'ko', 'nl', 'pl', 'pt-PT', 'ru', 'vi', 'zh-CN']
default_locale = locale.getlocale(locale.LC_MESSAGES)[0]
if default_locale is None:
@@ -114,7 +110,12 @@ class Common:
arch = 'linux64'
else:
arch = 'linux32'
- tarball_filename = 'tor-browser-'+arch+'-'+tbb_version+'_'+self.language+'.tar.xz'
+
+ if hasattr(self, 'settings') and self.settings['force_en-US']:
+ language = 'en-US'
+ else:
+ language = self.language
+ tarball_filename = 'tor-browser-'+arch+'-'+tbb_version+'_'+language+'.tar.xz'
# tarball
self.paths['tarball_url'] = '{0}torbrowser/'+tbb_version+'/'+tarball_filename
diff --git a/torbrowser_launcher/launcher.py b/torbrowser_launcher/launcher.py
index c7280ef..a24fa3e 100644
--- a/torbrowser_launcher/launcher.py
+++ b/torbrowser_launcher/launcher.py
@@ -47,6 +47,9 @@ class TryStableException(Exception):
class TryDefaultMirrorException(Exception):
pass
+class TryForcingEnglishException(Exception):
+ pass
+
class DownloadErrorException(Exception):
pass
@@ -166,6 +169,8 @@ class Launcher:
self.yes_button.connect("clicked", self.try_stable, None)
elif self.gui == 'error_try_default_mirror':
self.yes_button.connect("clicked", self.try_default_mirror, None)
+ elif self.gui == 'error_try_forcing_english':
+ self.yes_button.connect("clicked", self.try_forcing_english, None)
elif self.gui == 'error_try_tor':
self.yes_button.connect("clicked", self.try_tor, None)
self.button_box.add(self.yes_button)
@@ -300,6 +305,8 @@ class Launcher:
if response.code != 200:
if common.settings['mirror'] != common.default_mirror:
raise TryDefaultMirrorException(_("Download Error: {0} {1}\n\nYou are currently using a non-default mirror:\n{2}\n\nWould you like to switch back to the default?").format(response.code, response.phrase, common.settings['mirror']))
+ elif common.language != 'en-US' and not common.settings['force_en-US']:
+ raise TryForcingEnglishException(_("Download Error: {0} {1}\n\nWould you like to try the English version of Tor Browser instead?").format(response.code, response.phrase))
else:
raise DownloadErrorException(_("Download Error: {0} {1}").format(response.code, response.phrase))
@@ -353,6 +360,10 @@ class Launcher:
f.trap(TryDefaultMirrorException)
self.set_gui('error_try_default_mirror', str(f.value), [], False)
+ elif isinstance(f.value, TryForcingEnglishException):
+ f.trap(TryForcingEnglishException)
+ self.set_gui('error_try_forcing_english', str(f.value), [], False)
+
elif isinstance(f.value, DownloadErrorException):
f.trap(DownloadErrorException)
self.set_gui('error', str(f.value), [], False)
@@ -434,6 +445,13 @@ class Launcher:
subprocess.Popen([self.common.paths['tbl_bin']])
self.destroy(False)
+ def try_forcing_english(self, widget, data=None):
+ # change force english to true and relaunch TBL
+ self.common.settings['force_en-US'] = True
+ self.common.save_settings()
+ subprocess.Popen([self.common.paths['tbl_bin']])
+ self.destroy(False)
+
def try_tor(self, widget, data=None):
# set download_over_tor to true and relaunch TBL
self.common.settings['download_over_tor'] = True
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git
More information about the Pkg-privacy-commits
mailing list