From 251ef19666d1c4d4eabb4d3541d3826dd04674e8 Mon Sep 17 00:00:00 2001 From: MadcowOG Date: Thu, 5 May 2022 10:46:49 -0700 Subject: [PATCH] Using if else instead of try except. --- app/__init__.py | 7 ++++--- app/request.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 6d86e47..a720900 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -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 diff --git a/app/request.py b/app/request.py index f3a5258..a14a177 100644 --- a/app/request.py +++ b/app/request.py @@ -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." +