Beispiel #1
0
def start():
    global log
    settings = Settings()
    settings.getSettings()
    kl = KodiLogger()
    if settings.general['elevate_loglevel'] is True:
        kl.setLogLevel(xbmc.LOGINFO)
    else:
        kl.setLogLevel(xbmc.LOGDEBUG)
    log = kl.log
    log(msg=_('Settings read'))
    Cache.dispatcher = PubSub_Threaded.Dispatcher(
        interval=settings.general['TaskFreq'], sleepfxn=xbmc.sleep)
    log(msg=_('Dispatcher initialized'))

    subscriberfactory = SubscriberFactory(settings, kl)
    subscribers = subscriberfactory.createSubscribers()
    for subscriber in subscribers:
        Cache.dispatcher.addSubscriber(subscriber)
    publisherfactory = PublisherFactory(settings, subscriberfactory.topics,
                                        Cache.dispatcher, kl, debug)
    publisherfactory.createPublishers()
    Cache.publishers = publisherfactory.ipublishers

    Cache.dispatcher.start()
    log(msg=_('Dispatcher started'))

    for p in Cache.publishers:
        try:
            p.start()
        except threading.ThreadError:
            raise
    log(msg=_('Publisher(s) started'))
 def logSettings(self):
     import pprint
     settingspp = {
         'Tasks': self.tasks,
         'Events': self.events,
         'General': self.general
     }
     pp = pprint.PrettyPrinter(indent=2)
     msg = pp.pformat(settingspp)
     kl = KodiLogger()
     kl.log(msg=msg)
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from resources.lib.pubsub import TaskReturn
from resources.lib.utils.poutil import KodiPo
from resources.lib.kodilogging import KodiLogger
kl = KodiLogger()
log = kl.log
kodipo = KodiPo()
_ = kodipo.getLocalizedString


def testMsg(taskManager, taskSettings, kwargs):
    msg = [
        _('Testing for task type: %s') % taskSettings['type'],
        _('Settings: %s') % str(taskManager.taskKwargs),
        _('Runtime kwargs: %s') % str(kwargs)
    ]
    return msg


class TestHandler(object):
#
#    You should have received a copy of the GNU General Public License
#    along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import os
import codecs
import fnmatch
import re
import operator
import xbmcaddon
import threading
import copy
from resources.lib.utils.kodipathtools import translatepath
from resources.lib.kodilogging import KodiLogger
klogger = KodiLogger()
log = klogger.log

try:
    addonid = xbmcaddon.Addon().getAddonInfo('id')
except RuntimeError:
    addonid = 'script.service.kodi.callbacks'
if addonid == '':
    addonid = 'script.service.kodi.callbacks'


class KodiPo(object):

    _instance = None
    _lock = threading.Lock()