コード例 #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
 def create_temp():
     '''create temp folder for skin backup/restore'''
     temp_path = u'special://temp/skinbackup/'
     if xbmcvfs.exists(temp_path):
         recursive_delete_dir(temp_path)
         xbmc.sleep(2000)
     xbmcvfs.mkdir(temp_path)
     return temp_path
コード例 #3
0
ファイル: backuprestore.py プロジェクト: camster1/RTOTV
 def create_temp():
     '''create temp folder for skin backup/restore'''
     temp_path = u'%stemp/' % ADDON_DATA
     if xbmcvfs.exists(temp_path):
         recursive_delete_dir(temp_path)
         xbmc.sleep(2000)
     xbmcvfs.mkdirs(temp_path)
     xbmcvfs.mkdirs(temp_path + "skinbackup/")
     return temp_path
コード例 #4
0
 def create_temp():
     '''create temp folder for skin backup/restore'''
     temp_path = u'%stemp/' % ADDON_DATA
     # workaround weird slashes behaviour on some platforms.
     temp_path = temp_path.replace("//",
                                   "/").replace("special:/", "special://")
     if xbmcvfs.exists(temp_path):
         recursive_delete_dir(temp_path)
         xbmc.sleep(2000)
     xbmcvfs.mkdirs(temp_path)
     xbmcvfs.mkdirs(temp_path + "skinbackup/")
     return temp_path
コード例 #5
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))
コード例 #6
0
ファイル: backuprestore.py プロジェクト: camster1/RTOTV
    def backup(self, filters=None, backup_file="", silent=False):
        '''create skin backup'''
        if not filters:
            filters = []

        if not backup_file:
            return

        # create temp path
        temp_path = self.create_temp()
        zip_temp = u'%s/skinbackup-%s.zip' % (
            temp_path, datetime.now().strftime('%Y-%m-%d %H.%M'))
        temp_path = temp_path + "skinbackup/"

        # backup skinshortcuts preferences
        if not filters or (filters and "skinshortcuts" in filters):
            self.backup_skinshortcuts(temp_path + "skinshortcuts/")

        # backup skin settings
        if "skinshortcutsonly" not in filters:
            skinsettings_path = os.path.join(temp_path, u"guisettings.txt")
            self.backup_skinsettings(skinsettings_path, filters, temp_path)

        # zip the backup
        zip_temp = xbmc.translatePath(zip_temp).decode("utf-8")
        zip_tofile(temp_path, zip_temp)

        # copy to final location
        if xbmcvfs.exists(backup_file):
            xbmcvfs.delete(backup_file)
            xbmc.sleep(500)
            count = 20
            while xbmcvfs.exists(backup_file) and count:
                xbmc.sleep(500)
                count -= 1
        xbmcvfs.copy(zip_temp, backup_file)

        # cleanup temp
        recursive_delete_dir(temp_path)
        xbmcvfs.delete(zip_temp)

        # show success message
        if not silent:
            xbmcgui.Dialog().ok(self.addon.getLocalizedString(32004),
                                self.addon.getLocalizedString(32005))
コード例 #7
0
 def deletedir(self):
     '''helper to delete a directory, input can be normal filesystem path or vfs'''
     del_path = self.params.get("path")
     if del_path:
         ret = xbmcgui.Dialog().yesno(heading=xbmc.getLocalizedString(122),
                                      line1=u"%s[CR]%s" % (xbmc.getLocalizedString(125), del_path))
         if ret:
             success = recursive_delete_dir(del_path)
             if success:
                 xbmcgui.Dialog().ok(heading=xbmc.getLocalizedString(19179),
                                     line1=self.addon.getLocalizedString(32014))
             else:
                 xbmcgui.Dialog().ok(heading=xbmc.getLocalizedString(16205),
                                     line1=xbmc.getLocalizedString(32015))
コード例 #8
0
 def deletedir(self):
     '''helper to delete a directory, input can be normal filesystem path or vfs'''
     del_path = self.params.get("path")
     if del_path:
         ret = xbmcgui.Dialog().yesno(heading=xbmc.getLocalizedString(122),
                                      line1=u"%s[CR]%s" % (xbmc.getLocalizedString(125), del_path))
         if ret:
             success = recursive_delete_dir(del_path)
             if success:
                 xbmcgui.Dialog().ok(heading=xbmc.getLocalizedString(19179),
                                     line1=self.addon.getLocalizedString(32014))
             else:
                 xbmcgui.Dialog().ok(heading=xbmc.getLocalizedString(16205),
                                     line1=xbmc.getLocalizedString(32015))