[Pkg-privacy-commits] [torbrowser-launcher] 09/476: wrote code to figure out which language out of available languages to use, and creates local ~/.torbrowser directory structure
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:21:18 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository torbrowser-launcher.
commit 5628b31afe20aa00a9d85becac523dcd8eb0f7fd
Author: Micah Lee <micahflee at riseup.net>
Date: Thu Feb 7 10:10:12 2013 -0800
wrote code to figure out which language out of available languages to use, and creates local ~/.torbrowser directory structure
---
torbrowser-launcher | 54 +++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 44 insertions(+), 10 deletions(-)
diff --git a/torbrowser-launcher b/torbrowser-launcher
index e2fe460..8c3d9a3 100755
--- a/torbrowser-launcher
+++ b/torbrowser-launcher
@@ -15,7 +15,10 @@ class Base:
def destroy(self, widget, data=None):
gtk.main_quit()
- def __init__(self):
+ def __init__(self, tbb_version, tarball_url):
+ self.version = tbb_version
+ self.tarball_url = tarball_url
+
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Tor Browser Launcher - First Run")
self.window.set_border_width(10)
@@ -26,7 +29,7 @@ class Base:
self.box = gtk.VBox(False, 20)
self.window.add(self.box)
- self.label = gtk.Label("The first time you run the Tor Browser Launcher you need to download the Tor Browser Bundle from https://www.torproject.org/. Would you like to do that now?")
+ self.label = gtk.Label("The first time you run the Tor Browser Launcher you need to download the Tor Browser Bundle. Would you like to download it from the following URL now?\n\n"+self.tarball_url)
self.label.set_line_wrap(True)
self.box.pack_start(self.label, True, True, 0)
self.label.show()
@@ -52,14 +55,45 @@ class Base:
gtk.main()
if __name__ == "__main__":
- # figure out the language and architecture
- language = locale.getdefaultlocale()[0].split('_')[0]
+ # current TBB version
+ tbb_version = '2.3.25-2'
+
+ # figure out the architecture
architecture = subprocess.check_output(['arch']).strip('\n')
- # todo: is TBB already installed?
- # if yes, launch it
- # if no, show first run dialog
+ # figure out the language
+ available_languages = ['en-US', 'ar', 'de', 'es-ES', 'fa', 'fr', 'it', 'ko', 'nl', 'pl', 'pt-PT', 'ru', 'vi', 'zh-CN']
+ language = locale.getdefaultlocale()[0].replace('_', '-')
+ if language not in available_languages:
+ language = language.split('-')[0]
+ if language not in available_languages:
+ for l in available_languages:
+ if l[0:2] == language:
+ language = l
+ # if language isn't available, default to english
+ if language not in available_languages:
+ language = 'en-US'
+
+ # make sure local directory structure is setup
+ data_dir = os.getenv('HOME')+'/.torbrowser'
+ download_dir = data_dir+'/download'
+ tbb_dir = data_dir+'/tbb/'+architecture+'/'+language
+ if os.path.exists(download_dir) == False:
+ print 'making '+download_dir
+ os.makedirs(download_dir)
+ if os.path.exists(tbb_dir) == False:
+ print 'making '+tbb_dir
+ os.makedirs(tbb_dir)
+
+ # is TBB already installed?
+ tbb_start = tbb_dir+'/start-tor-browser'
+ if os.path.isfile(tbb_start):
+ print 'Launching '+tbb_start
+ subprocess.call([tbb_start])
+
+ else:
+ print 'Starting downloader'
+ tarball_url = 'https://www.torproject.org/dist/torbrowser/linux/tor-browser-gnu-linux-'+architecture+'-'+tbb_version+'-dev-'+language+'.tar.gz'
+ base = Base(tbb_version, tarball_url)
+ base.main()
- # first run dialog
- base = Base()
- base.main()
--
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