From fed8747e04115df16dda3615dd56c3fe36c19d00 Mon Sep 17 00:00:00 2001 From: Safihre Date: Fri, 28 Feb 2020 19:52:40 +0100 Subject: [PATCH] Correct getattr usage to hasattr --- SABnzbd.py | 4 ++-- sabnzbd/__init__.py | 2 +- sabnzbd/misc.py | 4 ++-- sabnzbd/osxmenu.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SABnzbd.py b/SABnzbd.py index d0b2604..acbf351 100755 --- a/SABnzbd.py +++ b/SABnzbd.py @@ -1466,7 +1466,7 @@ def main(): os.chdir(org_dir) # If OSX frozen restart of app instead of embedded python - if getattr(sys, 'frozen', None) and sabnzbd.DARWIN: + if hasattr(sys, "frozen") and sabnzbd.DARWIN: # [[NSProcessInfo processInfo] processIdentifier]] # logging.info("%s" % (NSProcessInfo.processInfo().processIdentifier())) my_pid = os.getpid() @@ -1501,7 +1501,7 @@ def main(): sys.stdout.flush() sabnzbd.pid_file() - if getattr(sys, 'frozen', None) and sabnzbd.DARWIN: + if hasattr(sys, "frozen") and sabnzbd.DARWIN: try: AppHelper.stopEventLoop() except: diff --git a/sabnzbd/__init__.py b/sabnzbd/__init__.py index 502c186..ce465a4 100644 --- a/sabnzbd/__init__.py +++ b/sabnzbd/__init__.py @@ -462,7 +462,7 @@ def trigger_restart(timeout=None): del_connection_info() # Leave the harder restarts to the polling in SABnzbd.py - if getattr(sys, "frozen", None): + if hasattr(sys, "frozen"): sabnzbd.TRIGGER_RESTART = True else: # Do the restart right now diff --git a/sabnzbd/misc.py b/sabnzbd/misc.py index d1283ed..c7e3d7c 100644 --- a/sabnzbd/misc.py +++ b/sabnzbd/misc.py @@ -461,7 +461,7 @@ def caller_name(skip=2): function_name = parentframe.f_code.co_name # Modulename not available in the binaries, we can use the filename instead - if getattr(sys, "frozen", None): + if hasattr(sys, "frozen"): module_name = inspect.getfile(parentframe) else: module_name = inspect.getmodule(parentframe).__name__ @@ -477,7 +477,7 @@ def exit_sab(value): """ Leave the program after flushing stderr/stdout """ sys.stderr.flush() sys.stdout.flush() - if getattr(sys, "frozen", None) and sabnzbd.DARWIN: + if hasattr(sys, "frozen") and sabnzbd.DARWIN: sabnzbd.SABSTOP = True from PyObjCTools import AppHelper AppHelper.stopEventLoop() diff --git a/sabnzbd/osxmenu.py b/sabnzbd/osxmenu.py index 2913b65..1a10db9 100644 --- a/sabnzbd/osxmenu.py +++ b/sabnzbd/osxmenu.py @@ -84,7 +84,7 @@ class SABnzbdDelegate(NSObject): self.status_item = status_bar.statusItemWithLength_(NSVariableStatusItemLength) for icon in status_icons: icon_path = status_icons[icon] - if getattr(sys, 'frozen', None): + if hasattr(sys, "frozen"): # Path is modified for the binary icon_path = os.path.join(os.path.dirname(sys.executable), '..', 'Resources', status_icons[icon]) self.icons[icon] = NSImage.alloc().initByReferencingFile_(icon_path)