[Pkg-privacy-commits] [torbrowser-launcher] 34/476: got all the tasks running in order

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 13:21:20 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 6105fb56279b67a8bb8873e7df5bf32d8bea52aa
Author: Micah Lee <micahflee at riseup.net>
Date:   Fri Feb 15 11:37:01 2013 -0800

    got all the tasks running in order
---
 torbrowser-launcher | 72 ++++++++++++++++++++++++++++++++---------------------
 1 file changed, 44 insertions(+), 28 deletions(-)

diff --git a/torbrowser-launcher b/torbrowser-launcher
index c0279aa..4eb542d 100755
--- a/torbrowser-launcher
+++ b/torbrowser-launcher
@@ -177,11 +177,6 @@ class TorBrowserLauncher:
       self.button_box.add(self.exit_button)
       self.exit_button.show()
 
-      # statusbar
-      self.statusbar = gtk.Label('')
-      self.statusbar.set_line_wrap(True)
-      self.box.pack_start(self.statusbar, True, True, 0)
-
     self.box.show()
     self.window.show();
 
@@ -189,32 +184,42 @@ class TorBrowserLauncher:
   def start(self, widget, data=None):
     # disable the start button
     self.start_button.set_sensitive(False)
+
+    # start running tasks
+    self.gui_task_i = 0
+    self.run_task()
+    
+  # run the next task in the task list
+  def run_task(self):
+    if self.gui_task_i >= len(self.gui_tasks):
+      self.destroy(False)
+      return
+
+    task = self.gui_tasks[self.gui_task_i]
     
-    # show the statusbar
-    #self.statusbar.show()
+    # get ready for the next task
+    self.gui_task_i += 1
 
-    # loop through tasks
-    for task in self.gui_tasks:
-      if task == 'download_tarball':
-        print 'Downloading '+self.paths['url']['tarball']
-        if not self.download('tarball', self.paths['url']['tarball'], self.paths['file']['tarball']):
-          self.start_button.set_sensitive(True)
-          break
+    if task == 'download_tarball':
+      print 'Downloading '+self.paths['url']['tarball']
+      self.download('tarball', self.paths['url']['tarball'], self.paths['file']['tarball'])
 
-      elif task == 'download_tarball_sig':
-        print 'Downloading '+self.paths['url']['tarball_sig']
-        if not self.download('signature', self.paths['url']['tarball_sig'], self.paths['file']['tarball_sig']):
-          self.start_button.set_sensitive(True)
-          break
+    elif task == 'download_tarball_sig':
+      print 'Downloading '+self.paths['url']['tarball_sig']
+      self.download('signature', self.paths['url']['tarball_sig'], self.paths['file']['tarball_sig'])
 
-      elif task == 'verify':
-        print 'Verifying signature'
+    elif task == 'verify':
+      print 'Verifying signature'
+      self.verify()
 
-      elif task == 'extract':
-        print 'Extracting '+self.paths['filename']['tarball']
+    elif task == 'extract':
+      print 'Extracting '+self.paths['filename']['tarball']
+      self.extract()
+
+    elif task == 'run':
+      print 'Running '+self.paths['file']['start']
+      self.run()
 
-      elif task == 'run':
-        print 'Running '+self.paths['file']['start']
 
   def download(self, name, url, path):
     # initialize the progress bar
@@ -229,12 +234,12 @@ class TorBrowserLauncher:
     self.dl_bytes_so_far = 0
 
     # set a timer to download more chunks
-    self.timer = gobject.timeout_add(1, self.download_chunk)
+    self.timer = gobject.timeout_add(1, self.download_chunk, name)
 
     # open a file to write to
     self.file_download = open(path, 'w')
 
-  def download_chunk(self):
+  def download_chunk(self, name):
     # download 10kb a time
     chunk = self.dl_response.read(10240)
     self.dl_bytes_so_far += len(chunk)
@@ -242,12 +247,14 @@ class TorBrowserLauncher:
 
     if not chunk:
       self.file_download.close()
+      # next task!
+      self.run_task()
       return False
 
     percent = float(self.dl_bytes_so_far) / self.dl_total_size
     self.progressbar.set_fraction(percent)
     percent = round(percent*100, 2)
-    self.progressbar.set_text("Downloaded %d" % (percent) + '%')
+    self.progressbar.set_text("Downloaded %d%% of %s" % (percent, name))
     
     sys.stdout.write("Downloaded %d of %d bytes (%0.2f%%)\r" % (self.dl_bytes_so_far, self.dl_total_size, percent))
 
@@ -256,6 +263,15 @@ class TorBrowserLauncher:
 
     return True
 
+  def verify(self):
+    self.run_task();
+
+  def extract(self):
+    self.run_task();
+
+  def run(self):
+    self.run_task();
+  
   # exit
   def delete_event(self, widget, event, data=None):
     return False

-- 
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