Generalize the handling of Tor exceptions, more logging in Web

This commit is contained in:
Micah Lee 2018-04-28 13:59:36 -07:00
parent 5d037a78fa
commit 1456361566
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 8 additions and 6 deletions

View File

@ -112,11 +112,11 @@ def main(cwd=None):
onion = Onion(common)
try:
onion.connect(custom_settings=False, config=config)
except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported, BundledTorTimeout) as e:
sys.exit(e.args[0])
except KeyboardInterrupt:
print("")
sys.exit()
except Exception as e:
sys.exit(e.args[0])
# Start the onionshare app
try:

View File

@ -417,11 +417,13 @@ class Web(object):
'data': data
})
def generate_slug(self, persistent_slug=''):
if persistent_slug:
def generate_slug(self, persistent_slug=None):
self.common.log('Web', 'generate_slug', 'persistent_slug={}'.format(persistent_slug))
if persistent_slug != None:
self.slug = persistent_slug
else:
self.slug = self.common.build_slug()
self.common.log('Web', 'generate_slug', 'slug is set to {}'.format(self.slug))
def debug_mode(self):
"""
@ -449,7 +451,7 @@ class Web(object):
raise RuntimeError('Not running with the Werkzeug Server')
func()
def start(self, port, stay_open=False, persistent_slug=''):
def start(self, port, stay_open=False, persistent_slug=None):
"""
Start the flask web server.
"""

View File

@ -142,7 +142,7 @@ class Mode(QtWidgets.QWidget):
self.app.start_onion_service()
self.starting_server_step2.emit()
except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorTimeout, OSError) as e:
except Exception as e:
self.starting_server_error.emit(e.args[0])
return