2018-11-19 00:59:17 +11:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import, division, unicode_literals
|
|
|
|
import Queue
|
|
|
|
from threading import Lock, RLock
|
|
|
|
|
|
|
|
from .. import utils
|
|
|
|
|
|
|
|
|
|
|
|
class App(object):
|
|
|
|
"""
|
|
|
|
This class is used to store variables across PKC modules
|
|
|
|
"""
|
|
|
|
def __init__(self, only_reload_settings=False):
|
|
|
|
self.load_settings()
|
|
|
|
if only_reload_settings:
|
|
|
|
return
|
|
|
|
# Quit PKC?
|
|
|
|
self.stop_pkc = False
|
2018-11-26 03:03:19 +11:00
|
|
|
# Shall we completely suspend PKC and our threads?
|
|
|
|
self.suspend = False
|
|
|
|
# Shall we only suspend threads?
|
|
|
|
self._suspend_threads = False
|
2018-11-19 00:59:17 +11:00
|
|
|
# Need to lock all methods and functions messing with Plex Companion subscribers
|
|
|
|
self.lock_subscriber = RLock()
|
|
|
|
# Need to lock everything messing with Kodi/PKC playqueues
|
|
|
|
self.lock_playqueues = RLock()
|
|
|
|
# Necessary to temporarily hold back librarysync/websocket listener when doing
|
|
|
|
# a full sync
|
|
|
|
self.lock_playlists = Lock()
|
|
|
|
|
|
|
|
# Plex Companion Queue()
|
|
|
|
self.companion_queue = Queue.Queue(maxsize=100)
|
|
|
|
# Command Pipeline Queue()
|
|
|
|
self.command_pipeline_queue = Queue.Queue()
|
|
|
|
# Websocket_client queue to communicate with librarysync
|
|
|
|
self.websocket_queue = Queue.Queue()
|
2018-11-21 02:58:25 +11:00
|
|
|
# xbmc.Monitor() instance from kodimonitor.py
|
|
|
|
self.monitor = None
|
2018-11-23 18:41:05 +11:00
|
|
|
# xbmc.Player() instance
|
|
|
|
self.player = None
|
2018-11-19 00:59:17 +11:00
|
|
|
|
|
|
|
def load_settings(self):
|
|
|
|
# Number of items to fetch and display in widgets
|
|
|
|
self.fetch_pms_item_number = int(utils.settings('fetch_pms_item_number'))
|
|
|
|
# Hack to force Kodi widget for "in progress" to show up if it was empty
|
|
|
|
# before
|
|
|
|
self.force_reload_skin = utils.settings('forceReloadSkinOnPlaybackStop') == 'true'
|
2018-11-26 03:03:19 +11:00
|
|
|
|
|
|
|
@property
|
|
|
|
def suspend_threads(self):
|
|
|
|
return self._suspend_threads or self.suspend
|
|
|
|
|
|
|
|
@suspend_threads.setter
|
|
|
|
def suspend_threads(self, value):
|
|
|
|
self._suspend_threads = value
|