コード例 #1
0
ファイル: colorthemes.py プロジェクト: camster1/RTOTV
    def restore_colortheme(self):
        '''restore zipbackup of colortheme to colorthemes folder'''
        zip_path = xbmcgui.Dialog().browse(
            1, self.addon.getLocalizedString(32030), "files", ".zip")
        if zip_path and zip_path.endswith(".zip"):

            # create temp path
            temp_path = u'special://temp/skinbackup/'
            temp_zip = u"special://temp/colortheme.zip"
            if xbmcvfs.exists(temp_path):
                recursive_delete_dir(temp_path)
            xbmcvfs.mkdir(temp_path)

            # unzip to temp
            xbmcvfs.copy(zip_path, temp_zip)
            unzip_fromfile(temp_zip, temp_path)
            for filename in xbmcvfs.listdir(temp_path)[1]:
                filename = filename.decode("utf-8")
                sourcefile = os.path.join(temp_path, filename)
                destfile = os.path.join(self.userthemes_path, filename)
                xbmcvfs.copy(sourcefile, destfile)
            # cleanup temp
            xbmcvfs.delete(temp_zip)
            recursive_delete_dir(temp_path)
            xbmcgui.Dialog().ok(self.addon.getLocalizedString(32026),
                                self.addon.getLocalizedString(32027))
コード例 #2
0
ファイル: backuprestore.py プロジェクト: camster1/RTOTV
    def restore(self, filename="", silent=False):
        '''restore skin settings from file'''

        if not filename:
            filename = self.get_restorefilename()

        progressdialog = None
        if not silent:
            progressdialog = xbmcgui.DialogProgress(
                self.addon.getLocalizedString(32006))
            progressdialog.create(self.addon.getLocalizedString(32007))

        if filename and xbmcvfs.exists(filename):
            # create temp path
            temp_path = self.create_temp()
            if not filename.endswith("zip"):
                # assume that passed filename is actually a guisettings file
                skinsettingsfile = filename
            else:
                # copy zip to temp directory and unzip
                skinsettingsfile = temp_path + "guisettings.txt"
                if progressdialog:
                    progressdialog.update(0, "unpacking backup...")
                zip_temp = u'%sskinbackup-%s.zip' % (
                    ADDON_DATA, datetime.now().strftime('%Y-%m-%d %H:%M'))
                xbmcvfs.copy(filename, zip_temp)
                unzip_fromfile(zip_temp, temp_path)
                xbmcvfs.delete(zip_temp)
                # copy skinshortcuts preferences
                self.restore_skinshortcuts(temp_path)
                # restore any custom skin images or themes
                for directory in ["custom_images/", "themes/"]:
                    custom_images_folder = u"special://profile/addon_data/%s/%s" % (
                        xbmc.getSkinDir(), directory)
                    custom_images_folder_temp = temp_path + directory
                    if xbmcvfs.exists(custom_images_folder_temp):
                        for file in xbmcvfs.listdir(
                                custom_images_folder_temp)[1]:
                            xbmcvfs.copy(custom_images_folder_temp + file,
                                         custom_images_folder + file)
            # restore guisettings
            if xbmcvfs.exists(skinsettingsfile):
                self.restore_guisettings(skinsettingsfile, progressdialog)

            # cleanup temp
            xbmc.sleep(500)
            recursive_delete_dir(temp_path)
            progressdialog.close()
            if not silent:
                xbmcgui.Dialog().ok(self.addon.getLocalizedString(32006),
                                    self.addon.getLocalizedString(32009))