Browse Source

Correct getattr usage to hasattr

pull/1399/head
Safihre 5 years ago
parent
commit
fed8747e04
  1. 4
      SABnzbd.py
  2. 2
      sabnzbd/__init__.py
  3. 4
      sabnzbd/misc.py
  4. 2
      sabnzbd/osxmenu.py

4
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:

2
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

4
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()

2
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)

Loading…
Cancel
Save