[Pkg-privacy-commits] [onionshare] 47/55: Enable stdout in Windows, OSX CLI versions (#305)

Ulrike Uhlig u-guest at moszumanska.debian.org
Thu Sep 8 10:27:43 UTC 2016


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

u-guest pushed a commit to branch debian
in repository onionshare.

commit 7a46336149a624d5cbc9b31959103cce82584b5f
Author: Micah Lee <micah at micahflee.com>
Date:   Tue Sep 6 12:09:10 2016 -0700

    Enable stdout in Windows, OSX CLI versions (#305)
---
 onionshare/web.py                | 15 ++++++++++++---
 onionshare_gui/onionshare_gui.py |  1 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/onionshare/web.py b/onionshare/web.py
index f32f13d..259bad1 100644
--- a/onionshare/web.py
+++ b/onionshare/web.py
@@ -123,6 +123,15 @@ def get_transparent_torification():
     """
     return transparent_torification
 
+# Are we running in GUI mode?
+gui_mode = False
+def set_gui_mode():
+    """
+    Tell the web service that we're running in GUI mode
+    """
+    global gui_mode
+    gui_mode = True
+
 def debug_mode():
     """
     Turn on debugging mode, which will log flask errors to a debug file.
@@ -213,7 +222,7 @@ def download(slug_candidate):
 
     def generate():
         # The user hasn't canceled the download
-        global client_cancel
+        global client_cancel, gui_mode
         client_cancel = False
 
         # Starting a new download
@@ -243,8 +252,8 @@ def download(slug_candidate):
                     downloaded_bytes = fp.tell()
                     percent = (1.0 * downloaded_bytes / zip_filesize) * 100
 
-                    # only output to stdout in Linux (#203, #304)
-                    if helpers.get_platform() == 'Linux':
+                    # only output to stdout if running onionshare in CLI mode, or if using Linux (#203, #304)
+                    if not gui_mode or helpers.get_platform() == 'Linux':
                         sys.stdout.write(
                             "\r{0:s}, {1:.2f}%          ".format(helpers.human_readable_filesize(downloaded_bytes), percent))
                         sys.stdout.flush()
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index 5fa8f62..032140d 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -139,6 +139,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
         # Reset web counters
         web.download_count = 0
         web.error404_count = 0
+        web.set_gui_mode()
 
         # pick an available local port for the http service to listen on
         self.app.choose_port()

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