Raise exception instead of using assert

This commit is contained in:
shortcutme 2019-07-03 18:35:55 +02:00
parent 80bfccd9d3
commit ff32f822ba
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE
7 changed files with 27 additions and 12 deletions

View file

@ -159,12 +159,14 @@ class TorManager(object):
else:
res_auth = self.send("AUTHENTICATE", conn)
assert "250 OK" in res_auth, "Authenticate error %s" % res_auth
if "250 OK" not in res_auth:
raise Exception("Authenticate error %s" % res_auth)
# Version 0.2.7.5 required because ADD_ONION support
res_version = self.send("GETINFO version", conn)
version = re.search(r'version=([0-9\.]+)', res_version).group(1)
assert float(version.replace(".", "0", 2)) >= 207.5, "Tor version >=0.2.7.5 required, found: %s" % version
if float(version.replace(".", "0", 2)) < 207.5:
raise Exception("Tor version >=0.2.7.5 required, found: %s" % version)
self.setStatus("Connected (%s)" % res_auth)
self.event_started.set(True)