def uninstall_plugin(plug): fileName = os.path.basename(plug[3]) fileName = os.path.splitext(fileName)[0] fileName = resources.createpath(resources.plugins, fileName + '.json') descriptor = open(fileName, 'r') plugin = json.load(descriptor) descriptor.close() module = plugin.get('module', False) if module: pluginDir = resources.createpath(resources.plugins, module) folders = [pluginDir] for root, dirs, files in os.walk(pluginDir): pluginFiles = [resources.createpath(root, f) for f in files] map(os.remove, pluginFiles) folders += [resources.createpath(root, d) for d in dirs] folders.reverse() for f in folders: if os.path.isdir(f): os.removedirs(f) os.remove(fileName) structure = {} if os.path.isfile(resources.descriptor): read = open(resources.descriptor, 'r') structure = json.load(read) read.close() structure.pop(module) descriptor = open(resources.descriptor, 'w') json.dump(structure, descriptor, indent=2)
def download_plugin(file_): fileName = resources.createpath(resources.plugins, os.path.basename(file_)) content = urllib.urlopen(file_) f = open(fileName, 'wb') f.write(content.read()) f.close() zipFile = zipfile.ZipFile(fileName, 'r') zipFile.extractall(resources.plugins) zipFile.close() os.remove(fileName)
def load_installed_plugin(plug): fileName = resources.createpath(resources.plugins, plug[0] + '.json') read = open(fileName, 'r') structure = json.load(read) read.close() module = structure.get('module', None) if module is not None: instance = load_module(module, resources.plugins) return [[instance, structure]] else: return []
def onWizardFinish(self, wizard): ids = wizard.pageIds() page = wizard.page(ids[1]) place = str(page.txtPlace.text()) if place == '': QMessageBox.critical(self, 'Incorrect Location', 'The project couldn\'t be create') return folder = str(page.txtFolder.text()).replace(' ', '_') path = resources.createpath(place, folder) if not manage_files.folder_exists(path): manage_files.create_folder(path) project = {} name = str(page.txtName.text()) project['name'] = name project['description'] = str(page.txtDescription.toPlainText()) project['license'] = str(page.cboLicense.currentText()) loader.create_ninja_project(path, name, project) self.load_project(path)
def onWizardFinish(self, wizard): ids = wizard.pageIds() page = wizard.page(ids[1]) place = str(page.txtPlace.text()) if place == "": QMessageBox.critical(self, "Incorrect Location", "The project couldn't be create") return folder = str(page.txtFolder.text()).replace(" ", "_") path = resources.createpath(place, folder) if not manage_files.folder_exists(path): manage_files.create_folder(path) project = {} name = str(page.txtName.text()) project["name"] = name project["description"] = str(page.txtDescription.toPlainText()) project["license"] = str(page.cboLicense.currentText()) loader.create_ninja_project(path, name, project) self.load_project(path)
def download(self, url, folder): fileName = resources.createpath(folder, os.path.basename(url)) content = urllib.urlopen(url) f = open(fileName, 'w') f.write(content.read()) f.close()
def add_toolbar_item(plug, instance, ide): icon = resources.createpath(resources.plugins, plug.get('icon', '')) ide.add_toolbar_item(instance, plug.get('name', ''), icon)
def add_properties_panel(plug, instance, ide): icon = resources.createpath(resources.plugins, plug.get('icon', '')) name = plug.get('name', '') widget = instance.propertiesWidget() ide.main._properties.add_tab(widget, name, icon)
def add_display(plug, instance, ide): icon = resources.createpath(resources.plugins, plug) ide.main.container.add_to_stack(instance.stackWidget(), icon)