def BACKUP_RD_TRAKT():

    if not os.path.exists(USB):
        os.makedirs(USB)
    vq = _get_keyboard(heading="Enter a name for this backup")
    if (not vq): return False, 0
    title = urllib.quote_plus(vq)
    backup_zip = xbmc.translatePath(
        os.path.join(USB, title + 'RD_Trakt_Settings.zip'))

    if not os.path.exists(EXCLUDES_FOLDER):
        os.makedirs(EXCLUDES_FOLDER)

    link = Common.OPEN_URL('http://pastebin.com/raw/CU2PSGze')
    plugins = re.compile('<plugin>(.+?)</plugin>').findall(link)
    for match in plugins:
        ADDONPATH = xbmc.translatePath(os.path.join(ADDON_DATA, match))
        ADDONSETTINGS = xbmc.translatePath(
            os.path.join(ADDONPATH, 'settings.xml'))
        EXCLUDEMOVE = xbmc.translatePath(
            os.path.join(EXCLUDES_FOLDER, match + '_settings.xml'))
        dialog = xbmcgui.Dialog()

        try:
            if os.path.exists(ADDONSETTINGS):
                copyfile(ADDONSETTINGS, EXCLUDEMOVE)
        except:
            pass

    exclude_dirs = [' ']
    exclude_files = [" "]
    message_header = "Creating full backup..."
    message_header2 = "Creating full backup..."
    message1 = "Archiving..."
    message2 = ""
    message3 = ""
    try:
        ARCHIVE_CB(EXCLUDES_FOLDER, backup_zip, message_header2, message1,
                   message2, message3, exclude_dirs, exclude_files)
    except:
        pass
    time.sleep(1)
    try:
        shutil.rmtree(EXCLUDEMOVE)
        shutil.rmdir(EXCLUDEMOVE)
    except:
        pass
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    dialog.ok("[COLOR green][B]SUCCESS![/B][/COLOR]",
              'The backup was completed successfully!.', "Backup Location: ",
              '[COLOR=yellow]' + backup_zip + '[/COLOR]')
Exemple #2
0
def Restore_RD_TRAKT():

    link = Common.OPEN_URL(BASEURL +
                           base64.b64decode(b'b3RoZXIvcmRfdHJha3QueG1s'))
    plugins = re.compile('<plugin>(.+?)</plugin>').findall(link)
    for match in plugins:
        ADDONPATH = xbmc.translatePath(os.path.join(ADDON_DATA, match))
        ADDONSETTINGS = xbmc.translatePath(
            os.path.join(ADDONPATH, 'settings.xml'))
        EXCLUDEMOVE = xbmc.translatePath(
            os.path.join(EXCLUDES_FOLDER, match + '_settings.xml'))
        if os.path.exists(EXCLUDEMOVE):
            if not os.path.exists(ADDONPATH):
                os.makedirs(ADDONPATH)
            if os.path.isfile(ADDONSETTINGS):
                os.remove(ADDONSETTINGS)
            os.rename(EXCLUDEMOVE, ADDONSETTINGS)
            try:
                os.remove(EXCLUDEMOVE)
            except:
                pass

    try:
        shutil.rmtree(EXCLUDEMOVE)
        shutil.rmdir(EXCLUDEMOVE)
    except:
        pass

    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()


#	service_url = BASEURL + base64.b64decode(b'b3RoZXIvcmRfdHJha3QueG1s')
#	f = urllib2.urlopen(service_url)
#	data = f.read()
#	f.close()
#
#	patron = "<items>(.*?)</items>"
#	addons = re.findall(patron,data,re.DOTALL)
#
#	items = []
#	for addon in addons:
#		item = {}
#		item["plugin"] = Common.find_single_match(addon,"<plugin>([^<]+)</plugin>")
#
#		if item["plugin"]!="":
#			items.append(item)
#
#		ADDONPATH = xbmc.translatePath(os.path.join(ADDON_DATA,item["plugin"]))
#		ADDONSETTINGS = xbmc.translatePath(os.path.join(ADDONPATH,'settings.xml'))
#		EXCLUDEMOVE = xbmc.translatePath(os.path.join(EXCLUDES_FOLDER,item["plugin"]+'_settings.xml'))
#		if os.path.exists(EXCLUDEMOVE):
#			if not os.path.exists(ADDONPATH):
#				os.makedirs(ADDONPATH)
#			if os.path.isfile(ADDONSETTINGS):
#				os.remove(ADDONSETTINGS)
#			os.rename(EXCLUDEMOVE, ADDONSETTINGS)
#			try:
#				os.remove(EXCLUDEMOVE)
#			except: pass
#
#	try:
#		shutil.rmtree(EXCLUDEMOVE)
#		shutil.rmdir(EXCLUDEMOVE)
#	except: pass
Exemple #3
0
def WIPE_BACKUPRESTORE():

    dp.create(ADDONTITLE, "Restoring Kodi.", 'In Progress.............',
              'Please Wait')
    try:
        for root, dirs, files in os.walk(HOME, topdown=True):
            dirs[:] = [d for d in dirs if d not in EXCLUDES]
            for name in files:
                try:
                    os.remove(os.path.join(root, name))
                    os.rmdir(os.path.join(root, name))
                except:
                    pass
            else:
                continue

            for name in dirs:
                try:
                    os.rmdir(os.path.join(root, name))
                    os.rmdir(root)
                except:
                    pass
    except:
        pass

    dp.create(ADDONTITLE, "Wiping Install", 'Removing empty folders.',
              'Please Wait')
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()

    if os.path.exists(NAVI):
        try:
            shutil.rmtree(NAVI)
        except:
            pass

    if os.path.exists(DATABASES):
        try:
            for root, dirs, files in os.walk(DATABASES, topdown=True):
                dirs[:] = [d for d in dirs]
                for name in files:
                    try:
                        os.remove(os.path.join(root, name))
                        os.rmdir(os.path.join(root, name))
                    except:
                        pass

                for name in dirs:
                    try:
                        os.rmdir(os.path.join(root, name))
                        os.rmdir(root)
                    except:
                        pass
        except:
            pass

    if os.path.exists(ADDON_DATA):
        try:
            for root, dirs, files in os.walk(ADDON_DATA, topdown=True):
                dirs[:] = [d for d in dirs]
                for name in files:
                    try:
                        os.remove(os.path.join(root, name))
                        os.rmdir(os.path.join(root, name))
                    except:
                        pass

                for name in dirs:
                    try:
                        os.rmdir(os.path.join(root, name))
                        os.rmdir(root)
                    except:
                        pass
        except:
            pass
Exemple #4
0
def FRESHSTART():

    choice = xbmcgui.Dialog().yesno(
        ADDONTITLE,
        '[COLOR lightskyblue][B]ARE YOU SURE YOU WANT TO RESTORE THE SYSTEM?[/B][/COLOR]',
        ' ',
        '[COLOR lightskyblue][B]EVERYTHING BAR THIS WIZARD WILL BE REMOVED[/B][/COLOR]',
        yeslabel='[B][COLOR green]YES[/COLOR][/B]',
        nolabel='[B][COLOR lightskyblue]NO[/COLOR][/B]')
    if choice == 0:
        sys.exit(1)

    skin = xbmc.getSkinDir()
    KODIV = float(xbmc.getInfoLabel("System.BuildVersion")[:4])
    skinswapped = 0

    #SWITCH THE SKIN IF THE CURRENT SKIN IS NOT CONFLUENCE
    if skin not in ['skin.confluence', 'skin.estuary']:
        skin = 'skin.estuary' if KODIV >= 17 else 'skin.confluence'
        skinSwitch.swapSkins(skin)
        skinswapped = 1
        time.sleep(1)

    #IF A SKIN SWAP HAS HAPPENED CHECK IF AN OK DIALOG (CONFLUENCE INFO SCREEN) IS PRESENT, PRESS OK IF IT IS PRESENT
    if skinswapped == 1:
        if not xbmc.getCondVisibility("Window.isVisible(yesnodialog)"):
            xbmc.executebuiltin("Action(Select)")

    #IF THERE IS NOT A YES NO DIALOG (THE SCREEN ASKING YOU TO SWITCH TO CONFLUENCE) THEN SLEEP UNTIL IT APPEARS
    if skinswapped == 1:
        while not xbmc.getCondVisibility("Window.isVisible(yesnodialog)"):
            time.sleep(1)

    #WHILE THE YES NO DIALOG IS PRESENT PRESS LEFT AND THEN SELECT TO CONFIRM THE SWITCH TO CONFLUENCE.
    if skinswapped == 1:
        while xbmc.getCondVisibility("Window.isVisible(yesnodialog)"):
            xbmc.executebuiltin("Action(Left)")
            xbmc.executebuiltin("Action(Select)")
            time.sleep(1)

    skin = xbmc.getSkinDir()

    #CHECK IF THE SKIN IS NOT CONFLUENCE
    if skin not in ['skin.confluence', 'skin.estuary']:
        choice = xbmcgui.Dialog().yesno(
            ADDONTITLE,
            '[COLOR lightskyblue][B]ERROR: AUTOSWITCH WAS NOT SUCCESSFUL[/B][/COLOR]',
            '[COLOR lightskyblue][B]CLICK YES TO MANUALLY SWITCH TO CONFLUENCE NOW[/B][/COLOR]',
            '[COLOR lightskyblue][B]YOU CAN PRESS NO AND ATTEMPT THE AUTO SWITCH AGAIN IF YOU WISH[/B][/COLOR]',
            yeslabel='[B][COLOR green]YES[/COLOR][/B]',
            nolabel='[B][COLOR lightskyblue]NO[/COLOR][/B]')
        if choice == 1:
            xbmc.executebuiltin("ActivateWindow(appearancesettings)")
            return
        else:
            sys.exit(1)

    dp.create(ADDONTITLE, "Restoring Kodi.", 'In Progress.............',
              'Please Wait')
    try:
        for root, dirs, files in os.walk(HOME, topdown=True):
            dirs[:] = [d for d in dirs if d not in EXCLUDES]
            for name in files:
                try:
                    os.remove(os.path.join(root, name))
                    os.rmdir(os.path.join(root, name))
                except:
                    pass

            for name in dirs:
                try:
                    os.rmdir(os.path.join(root, name))
                    os.rmdir(root)
                except:
                    pass
    except:
        pass

    dp.create(ADDONTITLE, "Wiping Install", 'Removing empty folders.',
              'Please Wait')
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()
    Common.REMOVE_EMPTY_FOLDERS()

    if os.path.exists(NAVI):
        try:
            shutil.rmtree(NAVI)
        except:
            pass

    if os.path.exists(DATABASES):
        try:
            for root, dirs, files in os.walk(DATABASES, topdown=True):
                dirs[:] = [d for d in dirs]
                for name in files:
                    try:
                        os.remove(os.path.join(root, name))
                        os.rmdir(os.path.join(root, name))
                    except:
                        pass

                for name in dirs:
                    try:
                        os.rmdir(os.path.join(root, name))
                        os.rmdir(root)
                    except:
                        pass
        except:
            pass

    if os.path.exists(ADDON_DATA):
        try:
            for root, dirs, files in os.walk(ADDON_DATA, topdown=True):
                dirs[:] = [d for d in dirs]
                for name in files:
                    try:
                        os.remove(os.path.join(root, name))
                        os.rmdir(os.path.join(root, name))
                    except:
                        pass

                for name in dirs:
                    try:
                        os.rmdir(os.path.join(root, name))
                        os.rmdir(root)
                    except:
                        pass
        except:
            pass

    Common.killxbmc()