mirror of
https://github.com/onionshare/onionshare.git
synced 2025-07-31 18:38:57 -04:00
Enable stdout in Windows, OSX CLI versions (#305)
This commit is contained in:
parent
f963cf9365
commit
c53d4f5e24
2 changed files with 13 additions and 3 deletions
|
@ -123,6 +123,15 @@ def get_transparent_torification():
|
||||||
"""
|
"""
|
||||||
return 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():
|
def debug_mode():
|
||||||
"""
|
"""
|
||||||
Turn on debugging mode, which will log flask errors to a debug file.
|
Turn on debugging mode, which will log flask errors to a debug file.
|
||||||
|
@ -213,7 +222,7 @@ def download(slug_candidate):
|
||||||
|
|
||||||
def generate():
|
def generate():
|
||||||
# The user hasn't canceled the download
|
# The user hasn't canceled the download
|
||||||
global client_cancel
|
global client_cancel, gui_mode
|
||||||
client_cancel = False
|
client_cancel = False
|
||||||
|
|
||||||
# Starting a new download
|
# Starting a new download
|
||||||
|
@ -243,8 +252,8 @@ def download(slug_candidate):
|
||||||
downloaded_bytes = fp.tell()
|
downloaded_bytes = fp.tell()
|
||||||
percent = (1.0 * downloaded_bytes / zip_filesize) * 100
|
percent = (1.0 * downloaded_bytes / zip_filesize) * 100
|
||||||
|
|
||||||
# only output to stdout in Linux (#203, #304)
|
# only output to stdout if running onionshare in CLI mode, or if using Linux (#203, #304)
|
||||||
if helpers.get_platform() == 'Linux':
|
if not gui_mode or helpers.get_platform() == 'Linux':
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
"\r{0:s}, {1:.2f}% ".format(helpers.human_readable_filesize(downloaded_bytes), percent))
|
"\r{0:s}, {1:.2f}% ".format(helpers.human_readable_filesize(downloaded_bytes), percent))
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
|
@ -139,6 +139,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||||
# Reset web counters
|
# Reset web counters
|
||||||
web.download_count = 0
|
web.download_count = 0
|
||||||
web.error404_count = 0
|
web.error404_count = 0
|
||||||
|
web.set_gui_mode()
|
||||||
|
|
||||||
# pick an available local port for the http service to listen on
|
# pick an available local port for the http service to listen on
|
||||||
self.app.choose_port()
|
self.app.choose_port()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue