From 20c277697e7ddd76aeebf9e3db875f3b69bcdb03 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> Date: Wed, 22 Sep 2021 15:55:39 +0200 Subject: [PATCH] LGTM recommendations: Except block handles 'BaseException' Except block directly handles BaseException. Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com> --- trojans/tncc-emulate.py | 8 ++++---- trojans/tncc-wrapper.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/trojans/tncc-emulate.py b/trojans/tncc-emulate.py index 5ef15dc1..338aaa17 100755 --- a/trojans/tncc-emulate.py +++ b/trojans/tncc-emulate.py @@ -504,11 +504,11 @@ class tncc(object): else: try: self.cj.set_cookie(dspreauth) - except: + except Exception: self.set_cookie('DSPREAUTH', dspreauth) try: self.cj.set_cookie(dssignin) - except: + except Exception: self.set_cookie('DSSIGNIN', dssignin) inner = self.gen_policy_request() @@ -580,7 +580,7 @@ class tncc(object): else: logging.warning('Unknown DN type %s', str(dn_name)) raise Exception() - except: + except Exception: fail = True break if fail: @@ -683,7 +683,7 @@ if __name__ == "__main__": mac = netifaces.ifaddresses(iface)[netifaces.AF_LINK][0]['addr'] assert mac != '00:00:00:00:00:00' mac_addrs.append(mac) - except: + except Exception: pass hostname = os.environ.get('TNCC_HOSTNAME', socket.gethostname()) diff --git a/trojans/tncc-wrapper.py b/trojans/tncc-wrapper.py index 60b7bb0f..a86b975e 100755 --- a/trojans/tncc-wrapper.py +++ b/trojans/tncc-wrapper.py @@ -53,7 +53,7 @@ class Tncc: try: if zipfile.ZipFile(self.tncc_jar, 'r').testzip() is not None: raise Exception() - except: + except Exception: print('Downloading tncc.jar...') os.makedirs(os.path.expanduser(TNCC_DIRECTORY), exist_ok=True) urllib.request.urlretrieve('https://' + self.vpn_host @@ -65,7 +65,7 @@ class Tncc: jar.getinfo(name.replace('.', '/') + '.class') self.class_name = name break - except: + except Exception: pass else: raise Exception('Could not find class name for', self.tncc_jar) -- 2.50.1