Esempio n. 1
0
def update_local_plugin_descriptor(plugins):
    '''
    updates the local plugin description
    The description.json file holds the information about the plugins
    downloaded with NINJA-IDE
    This is a way to track the versions of the plugins
    '''
    structure = []
    if os.path.isfile(resources.PLUGINS_DESCRIPTOR):
        structure = json_manager.read_json(resources.PLUGINS_DESCRIPTOR)
    for plug_list in plugins:
        #create the plugin data
        plug = {}
        plug['name'] = plug_list[0]
        plug['version'] = plug_list[1]
        plug['description'] = plug_list[2]
        plug['authors'] = plug_list[3]
        plug['home'] = plug_list[4]
        plug['download'] = plug_list[5]
        plug['plugin-descriptor'] = plug_list[6]
        #append the plugin data
        structure.append(plug)
    json_manager.write_json(structure, resources.PLUGINS_DESCRIPTOR)
Esempio n. 2
0
def update_local_plugin_descriptor(plugins):
    '''
    updates the local plugin description
    The description.json file holds the information about the plugins
    downloaded with NINJA-IDE
    This is a way to track the versions of the plugins
    '''
    structure = []
    if os.path.isfile(resources.PLUGINS_DESCRIPTOR):
        structure = json_manager.read_json(resources.PLUGINS_DESCRIPTOR)
    for plug_list in plugins:
        #create the plugin data
        plug = {}
        plug['name'] = plug_list[0]
        plug['version'] = plug_list[1]
        plug['description'] = plug_list[2]
        plug['authors'] = plug_list[3]
        plug['home'] = plug_list[4]
        plug['download'] = plug_list[5]
        plug['plugin-descriptor'] = plug_list[6]
        #append the plugin data
        structure.append(plug)
    json_manager.write_json(structure, resources.PLUGINS_DESCRIPTOR)
Esempio n. 3
0
def uninstall_plugin(plug):
    """
    Uninstall the given plugin
    """
    plugin_name = plug[0]
    structure = []
    if os.path.isfile(resources.PLUGINS_DESCRIPTOR):
        structure = json_manager.read_json(resources.PLUGINS_DESCRIPTOR)
    #copy the strcuture we iterate and remove at the same time
    structure_aux = copy.copy(structure)
    for plugin in structure_aux:
        if plugin["name"] == plugin_name:
            fileName = plugin["plugin-descriptor"]
            structure.remove(plugin)
            break
    #open <plugin>.plugin file and get the module to remove
    fileName = os.path.join(resources.PLUGINS, fileName)
    plugin = json_manager.read_json(fileName)
    module = plugin.get('module')
    if module:
        pluginDir = os.path.join(resources.PLUGINS, module)
        folders = [pluginDir]
        for root, dirs, files in os.walk(pluginDir):
            pluginFiles = [os.path.join(root, f) for f in files]
            #remove all files
            list(map(os.remove, pluginFiles))
            #collect subfolders
            folders += [os.path.join(root, d) for d in dirs]
        folders.reverse()
        for f in folders:
            if os.path.isdir(f):
                os.removedirs(f)
        #remove ths plugin_name.plugin file
        os.remove(fileName)
    #write the new info
    json_manager.write_json(structure, resources.PLUGINS_DESCRIPTOR)
Esempio n. 4
0
def uninstall_plugin(plug):
    """
    Uninstall the given plugin
    """
    plugin_name = plug[0]
    structure = []
    if os.path.isfile(resources.PLUGINS_DESCRIPTOR):
        structure = json_manager.read_json(resources.PLUGINS_DESCRIPTOR)
    #copy the strcuture we iterate and remove at the same time
    structure_aux = copy.copy(structure)
    for plugin in structure_aux:
        if plugin["name"] == plugin_name:
            fileName = plugin["plugin-descriptor"]
            structure.remove(plugin)
            break
    #open <plugin>.plugin file and get the module to remove
    fileName = os.path.join(resources.PLUGINS, fileName)
    plugin = json_manager.read_json(fileName)
    module = plugin.get('module')
    if module:
        pluginDir = os.path.join(resources.PLUGINS, module)
        folders = [pluginDir]
        for root, dirs, files in os.walk(pluginDir):
            pluginFiles = [os.path.join(root, f) for f in files]
            #remove all files
            list(map(os.remove, pluginFiles))
            #collect subfolders
            folders += [os.path.join(root, d) for d in dirs]
        folders.reverse()
        for f in folders:
            if os.path.isdir(f):
                os.removedirs(f)
        #remove ths plugin_name.plugin file
        os.remove(fileName)
    #write the new info
    json_manager.write_json(structure, resources.PLUGINS_DESCRIPTOR)