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 = try_encode('special://temp/skinbackup/') temp_zip = try_encode("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))
def restore(self, filename="", silent=False): '''restore skin settings from file''' if not filename: filename = self.get_restorefilename() #skip if filename is not a zip file if not filename.endswith("zip"): return 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 skinsettings 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 = try_encode( '%sskinbackup-%s.zip' % (ADDON_DATA, datetime.now().strftime('%Y-%m-%d-%H-%M'))) copy_file(filename, zip_temp, True) unzip_fromfile(zip_temp, temp_path) delete_file(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 = try_encode( "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 recursive_delete_dir(temp_path) progressdialog.close() if not silent: xbmcgui.Dialog().ok(self.addon.getLocalizedString(32006), self.addon.getLocalizedString(32009))