[Pkg-privacy-commits] [onionshare] 28/256: Merge branch 'master' of https://github.com/eightnoteight/onionshare into eightnoteight-master

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:06 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit eb00a29ca789ba4065535f754cf7d252457d001d
Merge: a67a037 3b11f4d
Author: Micah Lee <micah at micahflee.com>
Date:   Thu Dec 22 16:00:06 2016 -0800

    Merge branch 'master' of https://github.com/eightnoteight/onionshare into eightnoteight-master
    
    Conflicts:
    	onionshare/web.py
    	onionshare_gui/onionshare_gui.py
    	resources/locale/cs.json
    	resources/locale/eo.json
    	resources/locale/nl.json
    
    This merge required quite a bit of refactoring because.

 onionshare/helpers.py            | 11 ++++++-
 onionshare/web.py                |  4 +--
 onionshare_gui/onionshare_gui.py | 70 ++++++++++++++++++++++++++++++++++++++--
 resources/locale/cs.json         |  4 ++-
 resources/locale/en.json         |  3 +-
 resources/locale/eo.json         |  3 +-
 resources/locale/fi.json         |  3 +-
 resources/locale/it.json         |  5 +--
 resources/locale/nl.json         |  3 +-
 resources/locale/tr.json         |  3 +-
 10 files changed, 95 insertions(+), 14 deletions(-)

diff --cc onionshare/web.py
index 170775e,304c614..8af634e
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@@ -30,7 -30,8 +30,7 @@@ file_info = [
  zip_filename = None
  zip_filesize = None
  
- def set_file_info(filenames):
 -
+ def set_file_info(filenames, processed_size_callback=None):
      """
      Using the list of filenames being shared, fill in details that the web
      page will need to display. This includes zipping up the file in order to
diff --cc onionshare_gui/onionshare_gui.py
index 8a738d2,149f7e8..a6b8101
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@@ -155,65 -167,46 +158,79 @@@ class OnionShareGui(QtWidgets.QMainWind
          t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open, self.app.transparent_torification))
          t.daemon = True
          t.start()
 +        # wait for modules in thread to load, preventing a thread-related cx_Freeze crash
 +        time.sleep(0.2)
 +
 +        # start the onion service in a new thread
 +        def start_onion_service(self):
 +            self.status_bar.showMessage(strings._('gui_starting_server1', True))
 +            try:
 +                self.app.start_onion_service()
 +                self.starting_server_step2.emit()
 +
 +            except onionshare.onion.NoTor as e:
 +                self.starting_server_error.emit(e.args[0])
 +                return
 +
 +        t = threading.Thread(target=start_onion_service, kwargs={'self': self})
 +        t.daemon = True
 +        t.start()
  
 +    def start_server_step2(self):
 +        """
-         Step 2 in starting the onionshare server. Prepare files for serving.
++        Step 2 in starting the onionshare server. Zipping up files.
 +        """
+         # add progress bar to the status bar, indicating the crunching of files.
+         self._zip_progress_bar = ZipProgressBar(0)
+         self._zip_progress_bar.total_files_size = OnionShareGui._compute_total_size(
+             self.file_selection.file_list.filenames)
+         self.status_bar.clearMessage()
+         self.status_bar.insertWidget(0, self._zip_progress_bar)
+ 
          # prepare the files for sending in a new thread
          def finish_starting_server(self):
 +            # prepare files to share
-             web.set_file_info(self.file_selection.file_list.filenames)
+             def _set_processed_size(x):
+                 self._zip_progress_bar.processed_size = x
 -
 -            # prepare files to share
+             web.set_file_info(self.file_selection.file_list.filenames, processed_size_callback=_set_processed_size)
 -
              self.app.cleanup_filenames.append(web.zip_filename)
 -            self.starting_server_step2.emit()
 +            self.starting_server_step3.emit()
  
              # wait for hs
 -            if not self.app.local_only:
 +            if not self.app.local_only and not self.app.onion.supports_ephemeral:
                  self.status_bar.showMessage(strings._('gui_starting_server3', True))
 -                self.app.hs.wait_for_hs(self.app.onion_host)
 +                self.app.onion.wait_for_hs(self.app.onion_host)
  
              # done
              self.start_server_finished.emit()
  
-         self.status_bar.showMessage(strings._('gui_starting_server2', True))
++        #self.status_bar.showMessage(strings._('gui_starting_server2', True))
          t = threading.Thread(target=finish_starting_server, kwargs={'self': self})
          t.daemon = True
          t.start()
  
 -    @staticmethod
 -    def _compute_total_size(filenames):
 -        total_size = 0
 -        for filename in filenames:
 -            if os.path.isfile(filename):
 -                total_size += os.path.getsize(filename)
 -            if os.path.isdir(filename):
 -                total_size += helpers.dir_size(filename)
 -        return total_size
 +    def start_server_step3(self):
 +        """
 +        Step 3 in starting the onionshare server. This displays the large filesize
 +        warning, if applicable.
 +        """
++        # Remove zip progress bar
++        if self._zip_progress_bar is not None:
++            self.status_bar.removeWidget(self._zip_progress_bar)
++            self._zip_progress_bar = None
++
 +        # warn about sending large files over Tor
 +        if web.zip_filesize >= 157286400:  # 150mb
 +            self.filesize_warning.setText(strings._("large_filesize", True))
 +            self.filesize_warning.show()
 +
 +    def start_server_error(self, error):
 +        """
 +        If there's an error when trying to start the onion service
 +        """
 +        alert(error, QtWidgets.QMessageBox.Warning)
 +        self.server_status.stop_server()
 +        self.status_bar.clearMessage()
  
      def stop_server(self):
          """
@@@ -225,6 -218,6 +242,16 @@@
          self.filesize_warning.hide()
          self.stop_server_finished.emit()
  
++    @staticmethod
++    def _compute_total_size(filenames):
++        total_size = 0
++        for filename in filenames:
++            if os.path.isfile(filename):
++                total_size += os.path.getsize(filename)
++            if os.path.isdir(filename):
++                total_size += helpers.dir_size(filename)
++        return total_size
++
      def check_for_requests(self):
          """
          Check for messages communicated from the web app, and update the GUI accordingly.
@@@ -308,6 -294,41 +335,43 @@@
                  e.ignore()
  
  
+ class ZipProgressBar(QtWidgets.QProgressBar):
+     def __init__(self, total_files_size):
+         super(ZipProgressBar, self).__init__()
+         self.setMaximumHeight(15)
++        self.setMinimumWidth(200)
+         self.setValue(0)
+         self.setFormat(strings._('zip_progress_bar_format'))
+         self.setStyleSheet(
 -            "QProgressBar::chunk { background-color: #05B8CC; }")
++            "QProgressBar::chunk { background-color: #05B8CC; } "
++        )
+ 
+         self._total_files_size = total_files_size
+         self._processed_size = 0
+ 
+     @property
+     def total_files_size(self):
+         return self._total_files_size
+ 
+     @total_files_size.setter
+     def total_files_size(self, val):
+         self._total_files_size = val
+ 
+     @property
+     def processed_size(self):
+         return self._processed_size
+ 
+     @processed_size.setter
+     def processed_size(self, val):
+         self._processed_size = val
+         if self.processed_size < self.total_files_size:
+             self.setValue(int((self.processed_size * 100) / self.total_files_size))
+         elif self.total_files_size != 0:
+             self.setValue(100)
+         else:
+             self.setValue(0)
+ 
+ 
  def alert(msg, icon=QtWidgets.QMessageBox.NoIcon):
      """
      Pop up a message in a dialog window.
diff --cc resources/locale/cs.json
index f33491c,70b2a66..9be7c83
--- a/resources/locale/cs.json
+++ b/resources/locale/cs.json
@@@ -35,11 -35,12 +35,13 @@@
      "gui_downloads": "Stahování:",
      "gui_canceled": "Zrušeno",
      "gui_copied_url": "URL zkopírováno do schránky",
 -    "gui_starting_server1": "Spouštím Tor hidden service...",
 +    "gui_starting_server1": "Spouštím Tor onion service...",
      "gui_starting_server2": "Crunching files...",
 -    "gui_starting_server3": "Čekám na Tor hidden service...",
 +    "gui_starting_server3": "Čekám na Tor onion service...",
      "gui_please_wait": "Prosím čekejte...",
 -    "error_hs_dir_cannot_create": "Nejde vytvořit složka {0:s} pro hidden service",
 -    "error_hs_dir_not_writable": "Nejde zapisovat do složky {0:s} pro hidden service",
 -    "using_ephemeral": "Staring ephemeral Tor hidden service and awaiting publication",
 +    "error_hs_dir_cannot_create": "Nejde vytvořit složka {0:s} pro onion service",
 +    "error_hs_dir_not_writable": "Nejde zapisovat do složky {0:s} pro onion service",
-     "using_ephemeral": "Staring ephemeral Tor onion service and awaiting publication"
++    "using_ephemeral": "Staring ephemeral Tor onion service and awaiting publication",
+     "zip_progress_bar_format": "Crunching files: %p%"
++
  }
diff --cc resources/locale/nl.json
index ced76f0,da7370c..06ea85a
--- a/resources/locale/nl.json
+++ b/resources/locale/nl.json
@@@ -41,5 -41,6 +41,6 @@@
      "gui_please_wait": "Moment geduld...",
      "error_hs_dir_cannot_create": "Kan verborgen service map {0:s} niet aanmaken",
      "error_hs_dir_not_writable": "Verborgen service map {0:s} is niet schrijfbaar",
-     "using_ephemeral": "Kortstondige Tor onion service gestart en in afwachting van publicatie"
 -    "using_ephemeral": "Kortstondige Tor hidden service gestart en in afwachting van publicatie",
++    "using_ephemeral": "Kortstondige Tor onion service gestart en in afwachting van publicatie",
+     "zip_progress_bar_format": "Bestanden verwerken: %p%"
  }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list