Using if else instead of try except.
This commit is contained in:
parent
1fff49dc22
commit
251ef19666
|
@ -149,11 +149,12 @@ app.jinja_env.globals.update(
|
|||
Session(app)
|
||||
|
||||
# Attempt to acquire tor identity, to determine if Tor config is available
|
||||
try:
|
||||
confloc=os.getenv('WHOOGLE_TOR_CONF')
|
||||
if confloc is not None and os.path.isfile(confloc):
|
||||
send_tor_signal(
|
||||
Signal.HEARTBEAT,
|
||||
confloc=os.getenv('WHOOGLE_TOR_CONF'))
|
||||
except TypeError:
|
||||
confloc=confloc)
|
||||
else:
|
||||
send_tor_signal(Signal.HEARTBEAT)
|
||||
|
||||
from app import routes # noqa
|
||||
|
|
|
@ -64,6 +64,7 @@ def send_tor_signal(signal: Signal, confloc='./misc/tor/control.conf') -> bool:
|
|||
os.environ['TOR_AVAILABLE'] = '1'
|
||||
return True
|
||||
except (SocketError, ConnectionRefusedError, ConnectionError):
|
||||
# If neither words tor isn't configured correctly, or not set up.
|
||||
os.environ['TOR_AVAILABLE'] = '0'
|
||||
print(
|
||||
"Unable to authenticate with tor control port." +
|
||||
|
|
Loading…
Reference in New Issue
Block a user