示例#1
0
def CheckVersion():
    try:
        prev = ADDON.getSetting('VERSION')
        curr = VERSION

        if xbmcgui.Window(10000).getProperty('OTT_RUNNING') != 'True':
            VerifyKeymaps()

        if prev == curr:
            return

        verifySuperSearch()

        src = os.path.join(ROOT, 'cache')
        dst = os.path.join(ROOT, 'C')
        sfile.rename(src, dst)

        ADDON.setSetting('VERSION', curr)

        if prev == '0.0.0' or prev == '1.0.0':
            sfile.makedirs(PROFILE)

        #call showChangeLog like this to workaround bug in openElec
        script = os.path.join(HOME, 'showChangelog.py')
        cmd = 'AlarmClock(%s,RunScript(%s),%d,True)' % ('changelog', script, 0)
        xbmc.executebuiltin(cmd)
    except:
        pass
示例#2
0
def login_popup(message=None):
    dialog = xbmcgui.Dialog()
    additional = 'or register if you don have an account at sportsaccess.se'
    if message:
        additional = message
    ret = dialog.yesno('[COLOR red]SportsAccess[/COLOR]', 'Please check your SportsAccess credentials',
                       additional, '', 'Cancel', 'Login')
    if ret == 1:
        keyb = xbmc.Keyboard('', 'Enter Username')
        keyb.doModal()
        if (keyb.isConfirmed()):
            search = keyb.getText()
            username = search
            keyb = xbmc.Keyboard('', 'Enter Password:'******'skyusername', username)
                ADDON.setSetting('skypassword', password)
                return verify_login(username, password)

    return False
示例#3
0
def save_setting(key, value, is_list=False):

    xbmc.log(
        '[%s] Tyring to save setting: key "%s" / value "%s"' %
        (ADDON.getAddonInfo('id'), key, str(value)), xbmc.LOGDEBUG)

    file_path = xbmc.translatePath(
        os.path.join(ADDON.getAddonInfo('profile'), 'settings.xml'))
    if not os.path.exists(file_path):
        generate_settings_file(file_path)
    tree = eT.parse(file_path)
    root = tree.getroot()
    updated = False
    for item in root.findall('setting'):
        if item.attrib['id'] == key:
            if is_list:
                cur_values = item.attrib['value']
                if not cur_values:
                    cur_values = []
                else:
                    cur_values = json.loads(cur_values)
                if isinstance(value, list):
                    for val in value:
                        if val not in cur_values:
                            cur_values.append(val)
                else:
                    if value not in cur_values:
                        cur_values.append(value)
                item.attrib['value'] = json.dumps(cur_values)
                ADDON.setSetting(key, cur_values)
            else:
                item.attrib['value'] = value
                ADDON.setSetting(key, value)
            updated = True
    if updated:
        tree.write(file_path)
    return True
def save_setting(key, value, is_list=False):

    xbmc.log('[%s] Tyring to save setting: key "%s" / value "%s"' %
             (ADDON.getAddonInfo('id'), key, str(value)), xbmc.LOGDEBUG)

    file_path = xbmc.translatePath(
        os.path.join(ADDON.getAddonInfo('profile'), 'settings.xml'))
    if not os.path.exists(file_path):
        generate_settings_file(file_path)
    tree = eT.parse(file_path)
    root = tree.getroot()
    updated = False
    for item in root.findall('setting'):
        if item.attrib['id'] == key:
            if is_list:
                cur_values = item.attrib['value']
                if not cur_values:
                    cur_values = []
                else:
                    cur_values = json.loads(cur_values)
                if isinstance(value, list):
                    for val in value:
                        if val not in cur_values:
                            cur_values.append(val)
                else:
                    if value not in cur_values:
                        cur_values.append(value)
                item.attrib['value'] = json.dumps(cur_values)
                ADDON.setSetting(key, cur_values)
            else:
                item.attrib['value'] = value
                ADDON.setSetting(key, value)
            updated = True
    if updated:
        tree.write(file_path)
    return True
示例#5
0

if __name__ == '__main__':
    ok = True
    user = ADDON.getSetting('skyusername')
    passw = ADDON.getSetting('skypassword')
    if user == '' or passw == '':
        ok = login_popup()
    else:
        ok = verify_login(user, passw)

    if ok:
        # Apply Workaround for Kodi v17 on Android
        if xbmc.getCondVisibility('system.platform.android') and int(
                get_kodi_version()) == 17:
            ADDON.setSetting('background.stream', 'false')

        # After a restart the proc file should be wiped!
        f = open(PROC_FILE, 'w')
        f.write('')
        f.close()

        try:
            w = gui.TVGuide()
            w.doModal()
            del w

        except:
            import sys
            import traceback as tb
            (etype, value, traceback) = sys.exc_info()