mirror of
https://github.com/torproject/torbrowser-launcher.git
synced 2024-11-24 01:49:59 +00:00
wrote code to figure out which language out of available languages to use, and creates local ~/.torbrowser directory structure
This commit is contained in:
parent
f928ee4fc1
commit
5628b31afe
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user