[Pkg-privacy-commits] [onionshare] 165/256: Fixed various issues introduced by creating an singleton Onion object and passing it into the OnionShare object
Ulrike Uhlig
ulrike at moszumanska.debian.org
Fri May 26 12:53:33 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 dc23946fe87a4d0292dcf3b6cc727a1dc46a3996
Author: Micah Lee <micah at micahflee.com>
Date: Sun May 14 17:21:13 2017 -0700
Fixed various issues introduced by creating an singleton Onion object and passing it into the OnionShare object
---
onionshare/__init__.py | 1 +
onionshare/onionshare.py | 5 +----
onionshare_gui/__init__.py | 2 +-
onionshare_gui/onionshare_gui.py | 32 ++++++++++----------------------
4 files changed, 13 insertions(+), 27 deletions(-)
diff --git a/onionshare/__init__.py b/onionshare/__init__.py
index 4340b50..2005473 100644
--- a/onionshare/__init__.py
+++ b/onionshare/__init__.py
@@ -128,6 +128,7 @@ def main(cwd=None):
finally:
# Shutdown
app.cleanup()
+ onion.cleanup()
if __name__ == '__main__':
main()
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index 71189fe..ac5f6fa 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -52,6 +52,7 @@ class OnionShare(object):
"""
Start the onionshare onion service.
"""
+ # Choose a random port
self.port = helpers.get_available_port(17600, 17650)
if self.local_only:
@@ -74,7 +75,3 @@ class OnionShare(object):
elif os.path.isdir(filename):
shutil.rmtree(filename)
self.cleanup_filenames = []
-
- # cleanup the onion
- if self.onion:
- self.onion.cleanup()
diff --git a/onionshare_gui/__init__.py b/onionshare_gui/__init__.py
index 8a8b955..d0fb365 100644
--- a/onionshare_gui/__init__.py
+++ b/onionshare_gui/__init__.py
@@ -105,7 +105,7 @@ def main():
# Start the OnionShare app
web.set_stay_open(stay_open)
- app = OnionShare(debug, local_only, stay_open)
+ app = OnionShare(onion, debug, local_only, stay_open)
# Clean up when app quits
def shutdown():
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index 7f18353..badc10e 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -22,6 +22,7 @@ from PyQt5 import QtCore, QtWidgets, QtGui
from onionshare import strings, helpers, web
from onionshare.settings import Settings
+from onionshare.onion import *
from .menu import Menu
from .file_selection import FileSelection
@@ -145,36 +146,23 @@ class OnionShareGui(QtWidgets.QMainWindow):
web.error404_count = 0
web.set_gui_mode()
- # pick an available local port for the http service to listen on
- self.app.choose_port()
-
- # start onionshare http service in new thread
- t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open))
- 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):
try:
- # Show Tor connection status if connection type is bundled tor
- if settings.get('connection_type') == 'bundled':
- def bundled_tor_func(message):
- self.status_bar.showMessage(message)
- if 'Done' in message:
- self.status_bar.showMessage(strings._('gui_starting_server1', True))
- else:
- self.status_bar.showMessage(strings._('gui_starting_server1', True))
- bundled_tor_func = None
-
- self.app.start_onion_service(bundled_tor_func)
+ self.app.start_onion_service()
self.starting_server_step2.emit()
- except (onionshare.onion.TorTooOld, onionshare.onion.TorErrorInvalidSetting, onionshare.onion.TorErrorAutomatic, onionshare.onion.TorErrorSocketPort, onionshare.onion.TorErrorSocketFile, onionshare.onion.TorErrorMissingPassword, onionshare.onion.TorErrorUnreadableCookieFile, onionshare.onion.TorErrorAuthError, onionshare.onion.TorErrorProtocolError, onionshare.onion.BundledTorTimeout) as e:
+ except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorTimeout) as e:
self.starting_server_error.emit(e.args[0])
return
+ # start onionshare http service in new thread
+ t = threading.Thread(target=web.start, args=(self.app.port, self.app.stay_open))
+ t.daemon = True
+ t.start()
+ # wait for modules in thread to load, preventing a thread-related cx_Freeze crash
+ time.sleep(0.2)
+
t = threading.Thread(target=start_onion_service, kwargs={'self': self})
t.daemon = True
t.start()
--
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