import os-specific module after plugin init

This commit is contained in:
snow flurry 2023-07-26 14:07:10 -07:00
parent 97b34f6334
commit d7fa0f15f4

View file

@ -7,13 +7,6 @@ except ImportError:
import_ok = False
import sys
try:
import importlib
notify = importlib.import_module("notify_%s" % sys.platform)
except ImportError:
weechat.prnt('', 'No OS-specific module notify_%s found.' % sys.platform)
import_ok = False
SCRIPT_AUTHOR = 'snow flurry <snow@datagirl.xyz>'
SCRIPT_NAME = 'away_on_lock'
@ -75,4 +68,12 @@ elif __name__ == "__main__":
print('This script must be run from WeeChat.')
sys.exit(1)
notify.notify_lock(lambda status: print(status))
# pyobjc gets upset if we reimport in the same exec runtime, so
# wait to import it until here!
try:
import importlib
notify = importlib.import_module("notify_%s" % sys.platform)
except ImportError:
print('No OS-specific module notify_%s found.' % sys.platform, file=sys.stderr)
notify.notify_lock(lambda status: print(status))