def createUserTasks():
    paths = [translatepath('special://addondata')]
    try:
        setPathRW(paths[0])
    except OSError:
        pass
    paths.append(os.path.join(paths[0], 'lib'))
    paths.append(os.path.join(paths[1], 'usertasks'))
    for path in paths:
        if not os.path.isdir(path):
            try:
                os.mkdir(path)
                setPathExecuteRW(path)
            except OSError:
                pass
    for path in paths[1:]:
        fn = os.path.join(path, '__init__.py')
        if not os.path.isfile(fn):
            try:
                with open(fn, mode='w') as f:
                    f.writelines('')
                setPathExecuteRW(fn)
            except (OSError, IOError):
                pass
def createUserTasks():
    paths = [translatepath('special://addondata')]
    try:
        setPathRW(paths[0])
    except OSError:
        pass
    paths.append(os.path.join(paths[0], 'lib'))
    paths.append(os.path.join(paths[1], 'usertasks'))
    for path in paths:
        if not os.path.isdir(path):
            try:
                os.mkdir(path)
                setPathExecuteRW(path)
            except OSError:
                pass
    for path in paths[1:]:
        fn = os.path.join(path, '__init__.py')
        if not os.path.isfile(fn):
            try:
                with open(fn, mode='w') as f:
                    f.writelines('')
                setPathExecuteRW(fn)
            except (OSError, IOError):
                pass
import json
from resources.lib import taskdict
from resources.lib.pubsub import Topic, TaskManager
from resources.lib.events import Events
from resources.lib.kodilogging import KodiLogger
from resources.lib.utils.kodipathtools import translatepath, setPathExecuteRW
import xbmc
from resources.lib.utils.poutil import KodiPo
kodipo = KodiPo()
_ = kodipo.getLocalizedString
kl = KodiLogger()
log = kl.log
events = Events().AllEvents
isAndroid = 'XBMC_ANDROID_SYSTEM_LIBS' in os.environ.keys()
testdir = translatepath('special://addon/resources/lib/tests')
setPathExecuteRW(testdir)


def is_xbmc_debug():
    json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Settings.GetSettingValue", "params": {"setting":"debug.showloginfo"} }')
    json_query = str(json_query)
    json_response = json.loads(json_query)
    if json_response.has_key('result'):
        if json_response['result'].has_key('value'):
            return json_response['result']['value']
        else:
            raise SyntaxError('Bad JSON')
    else:
        raise SyntaxError('Bad JSON')

import json
from resources.lib import taskdict
from resources.lib.pubsub import Topic, TaskManager
from resources.lib.events import Events
from resources.lib.kodilogging import KodiLogger
from resources.lib.utils.kodipathtools import translatepath, setPathExecuteRW
import xbmc
from resources.lib.utils.poutil import KodiPo
kodipo = KodiPo()
_ = kodipo.getLocalizedString
kl = KodiLogger()
log = kl.log
events = Events().AllEvents
isAndroid = 'XBMC_ANDROID_SYSTEM_LIBS' in os.environ.keys()
testdir = translatepath('special://addon/resources/lib/tests')
setPathExecuteRW(testdir)


def is_xbmc_debug():
    json_query = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Settings.GetSettingValue", "params": {"setting":"debug.showloginfo"} }')
    json_query = unicode(json_query, 'utf-8', errors='ignore')
    json_response = json.loads(json_query)
    if json_response.has_key('result'):
        if json_response['result'].has_key('value'):
            return json_response['result']['value']
        else:
            raise SyntaxError('Bad JSON')
    else:
        raise SyntaxError('Bad JSON')