Using if else instead of try except.

This commit is contained in:
MadcowOG 2022-05-05 10:46:49 -07:00
parent 1fff49dc22
commit 251ef19666
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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." +