def restore(): dialog = xbmcgui.Dialog() backup = dialog.browse( 1, utils.get_string(30075), "files", mask=".zip", defaultt=_backup_location ) if backup.endswith("zip"): with zipfile.ZipFile(backup, "r") as z: info = z.infolist() choice = dialog.yesno( "AutoWidget", utils.get_string(30076).format(len(info), "s" if len(info) > 1 else ""), ) if choice: overwrite = dialog.yesno("AutoWidget", utils.get_string(30077)) if overwrite: files = [x for x in os.listdir(_addon_data) if x.endswith(".group")] for file in files: utils.remove_file(file) z.extractall(_addon_data) else: dialog.notification("AutoWidget", utils.get_string(30078)) del dialog else: dialog.notification("AutoWidget", utils.get_string(30078)) del dialog return
def restore(): backup = dialog.browse(1, utils.get_string(32098), 'files', mask='.zip', defaultt=_backup_location) if backup.endswith('zip'): with zipfile.ZipFile(backup, 'r') as z: info = z.infolist() choice = dialog.yesno( 'AutoWidget', utils.get_string(32099).format(len(info), 's' if len(info) > 1 else '')) if choice: overwrite = dialog.yesno('AutoWidget', utils.get_string(32100)) if overwrite: files = [ x for x in os.listdir(utils._addon_path) if x.endswith('.group') ] for file in files: utils.remove_file(file) z.extractall(utils._addon_path) else: dialog.notification('AutoWidget', utils.get_string(32101)) else: dialog.notification('AutoWidget', utils.get_string(32101)) return
def restore(): backup = dialog.browse(1, utils.get_string(32098), "files", mask=".zip", defaultt=_backup_location) if backup.endswith("zip"): with zipfile.ZipFile(backup, "r") as z: info = z.infolist() choice = dialog.yesno( "AutoWidget", utils.get_string(32099).format(len(info), "s" if len(info) > 1 else ""), ) if choice: overwrite = dialog.yesno("AutoWidget", utils.get_string(32100)) if overwrite: files = [ x for x in os.listdir(utils._addon_path) if x.endswith(".group") ] for file in files: utils.remove_file(file) z.extractall(utils._addon_path) else: dialog.notification("AutoWidget", utils.get_string(32101)) else: dialog.notification("AutoWidget", utils.get_string(32101)) return
def remove_widget(widget_id, over=False): if not over: choice = dialog.yesno('AutoWidget', utils.get_string(32039)) if over or choice: file = os.path.join(utils._addon_path, '{}.widget'.format(widget_id)) utils.remove_file(file) dialog.notification('AutoWidget', utils.get_string(32045).format(widget_id))
def remove_widget(widget_id, over=False): if not over: choice = dialog.yesno("AutoWidget", utils.get_string(30025)) if over or choice: file = os.path.join(utils._addon_path, "{}.widget".format(widget_id)) utils.remove_file(file) dialog.notification("AutoWidget", utils.get_string(30030).format(widget_id))
def _remove_widget(widget_id): dialog = xbmcgui.Dialog() choice = dialog.yesno('AutoWidget', utils.get_string(32039)) if choice: file = os.path.join(_addon_path, '{}.widget'.format(widget_id)) utils.remove_file(file) dialog.notification('AutoWidget', utils.get_string(32045).format(widget_id))
def _remove_group(group_id, over=False): group_def = manage.get_group_by_id(group_id) group_name = group_def['label'] if not over: choice = dialog.yesno('AutoWidget', utils.get_string(32039)) if over or choice: file = os.path.join(utils._addon_path, '{}.group'.format(group_id)) utils.remove_file(file) dialog.notification('AutoWidget', utils.get_string(32045).format(group_name))
def _remove_group(group_id, over=False): group_def = manage.get_group_by_id(group_id) group_name = group_def["label"] if not over: choice = dialog.yesno("AutoWidget", utils.get_string(32039)) if over or choice: file = os.path.join(utils._addon_path, "{}.group".format(group_id)) utils.remove_file(file) dialog.notification( "AutoWidget", utils.get_string(32045).format(six.text_type(group_name)))
def _remove_group(group_id, over=False): dialog = xbmcgui.Dialog() group_def = manage.get_group_by_id(group_id) group_name = group_def["label"] if not over: choice = dialog.yesno("AutoWidget", utils.get_string(30025)) if over or choice: file = os.path.join(_addon_data, "{}.group".format(group_id)) utils.remove_file(file) dialog.notification( "AutoWidget", utils.get_string(30030).format(six.text_type(group_name))) del dialog
def clean(widget_id=None, notify=False, all=False): if all: for widget in find_defined_widgets(): clean(widget_id=widget["id"]) return find_defined_widgets() files = [] dialog = xbmcgui.Dialog() skin_shortcuts = os.path.join(utils._addon_data, "script.skinshortcuts") params = { "jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddons", "params": {"type": "xbmc.gui.skin"}, } addons = json.loads(utils.call_jsonrpc(json.dumps(params))) if "error" not in addons: for addon in addons["result"]["addons"]: path = os.path.join(utils._addon_data, addon["addonid"], "settings.xml") if os.path.exists(path): files.append(path) if os.path.exists(skin_shortcuts): for xml in os.listdir(skin_shortcuts): ext = xml.split(".") if ext[-1] in ["xml", "properties"]: path = os.path.join(skin_shortcuts, xml) files.append(path) remove = [] removed = 0 if widget_id: found = False for file in files: if widget_id in utils.read_file(file): found = True utils.log("{} found in {}; not cleaning".format(widget_id, file)) break if not found: utils.log("{} not found; cleaning".format(widget_id)) utils.remove_file( os.path.join(utils._addon_path, "{}.widget".format(widget_id)) ) return True return False for widget in find_defined_widgets(): found = False if get_group_by_id(widget["group"]): found = True else: for file in files: if widget["id"] in utils.read_file(file): found = True utils.log("{} found in {}; not cleaning".format(widget["id"], file)) break if not found: utils.log("{} not found; cleaning".format(widget["id"])) utils.remove_file( os.path.join(utils._addon_path, "{}.widget".format(widget["id"])) ) removed += 1 if notify: dialog.notification( "AutoWidget", utils.get_string(30106).format("No" if removed == 0 else removed), )
def clean(widget_id=None, notify=False): files = [] dialog = xbmcgui.Dialog() skin_shortcuts = os.path.join(utils._addon_data, 'script.skinshortcuts') params = { "jsonrpc": "2.0", "id": 1, "method": "Addons.GetAddons", "params": { "type": "xbmc.gui.skin" } } addons = json.loads(utils.call_jsonrpc(json.dumps(params))) if 'error' not in addons: for addon in addons['result']['addons']: path = os.path.join(utils._addon_data, addon['addonid'], 'settings.xml') if os.path.exists(path): files.append(path) if os.path.exists(skin_shortcuts): for xml in os.listdir(skin_shortcuts): ext = xml.split('.') if ext[-1] in ['xml', 'properties']: path = os.path.join(skin_shortcuts, xml) files.append(path) remove = [] removed = 0 if widget_id: found = False for file in files: if widget_id in utils.read_file(file): found = True utils.log('{} found in {}; not cleaning'.format( widget_id, file)) break if not found: utils.log('{} not found; cleaning'.format(widget_id)) utils.remove_file( os.path.join(utils._addon_path, '{}.widget'.format(widget_id))) return True return False for widget in find_defined_widgets(): found = False if get_group_by_id(widget['group']): found = True else: for file in files: if widget['id'] in utils.read_file(file): found = True utils.log('{} found in {}; not cleaning'.format( widget['id'], file)) break if not found: utils.log('{} not found; cleaning'.format(widget['id'])) utils.remove_file( os.path.join(utils._addon_path, '{}.widget'.format(widget['id']))) removed += 1 if notify: dialog.notification( 'AutoWidget', utils.get_string(32132).format('No' if removed == 0 else removed))
def remove_cache_queue(hash): queue_path = os.path.join(_addon_data, "{}.queue".format(hash)) utils.remove_file(queue_path)