Show missing pyobjc module message on MacOS menu bar setting

This commit is contained in:
JonnyWong16 2020-06-14 15:22:58 -07:00
parent 451feda86b
commit 89307dad01
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
4 changed files with 19 additions and 12 deletions

View file

@ -257,15 +257,12 @@ def main():
plexpy.HTTP_ROOT)
if common.PLATFORM == 'Darwin' and plexpy.CONFIG.SYS_TRAY_ICON:
try:
import AppKit
import Foundation
except ImportError:
if not macos.HAS_PYOBJC:
logger.warn("The pyobjc module is missing. Install this "
"module to enable the menu bar icon.")
"module to enable the MacOS menu bar icon.")
plexpy.CONFIG.SYS_TRAY_ICON = False
if plexpy.CONFIG.SYS_TRAY_ICON and macos.has_rumps:
if plexpy.CONFIG.SYS_TRAY_ICON:
# MacOS menu bar icon must be run on the main thread and is blocking
# Start the rest of Tautulli on a new thread
threading.Thread(target=wait).start()

View file

@ -2161,7 +2161,7 @@ div.advanced-setting {
li.advanced-setting {
border-left: 1px solid #cc7b19;
}
.docker-setting {
.setting-message {
color: #cc7b19;
margin-left: 10px;
}

View file

@ -8,7 +8,7 @@
from plexpy.helpers import anon_url, checked
docker_setting = 'disabled' if plexpy.DOCKER else ''
docker_msg = '<span class="docker-setting small">(Controlled by Docker Container)</span>' if plexpy.DOCKER else ''
docker_msg = '<span class="setting-message small">(Controlled by Docker Container)</span>' if plexpy.DOCKER else ''
available_notification_agents = sorted(notifiers.available_notification_agents(), key=lambda k: k['label'].lower())
available_newsletter_agents = sorted(newsletters.available_newsletter_agents(), key=lambda k: k['label'].lower())
@ -460,10 +460,16 @@
% if common.PLATFORM in ('Windows', 'Darwin'):
<%
tray = {'Windows': 'System Tray', 'Darwin': 'Menu Bar'}
tray_disabled = tray_disabled_msg = ''
if common.PLATFORM == 'Darwin':
from plexpy.macos import HAS_PYOBJC
if not HAS_PYOBJC:
tray_disabled = 'disabled'
tray_disabled_msg = '<span class="setting-message small">(Missing pyobjc module)</span>'
%>
<div class="checkbox">
<label>
<input type="checkbox" class="http-settings" name="sys_tray_icon" id="sys_tray_icon" value="1" ${config['sys_tray_icon']}> Enable ${tray[common.PLATFORM]} Icon
<input type="checkbox" class="http-settings" name="sys_tray_icon" id="sys_tray_icon" value="1" ${config['sys_tray_icon']} ${tray_disabled}> Enable ${tray[common.PLATFORM]} Icon ${tray_disabled_msg | n}
</label>
<p class="help-block">Show Tautulli shortcut in the ${tray[common.PLATFORM].lower()}.</p>
</div>

View file

@ -21,10 +21,14 @@ import sys
import plistlib
try:
import rumps
has_rumps = True
import AppKit
import Foundation
HAS_PYOBJC = True
except ImportError:
has_rumps = False
HAS_PYOBJC = False
if HAS_PYOBJC:
import rumps
import plexpy
if plexpy.PYTHON2: