def saveTableFromWidget(display, path): if path is None or len(path) <= 0: raise Exception("Invalid or empty file name") path = FileUtil.workspacePathToSysPath(path) if path is None: raise Exception("Save Error", "Invalid file name or path") table_scan = getTableFromWidget(display) table_scan.save(path) # Force a workspace refresh on the new file ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(Path(path)).refreshLocal(0, None)
def saveTableFromWidget(display, path): if path is None or len(path) <= 0: raise Exception("Invalid or empty file name") path = FileUtil.workspacePathToSysPath(path) if path is None: raise Exception("Save Error", "Invalid file name or path") table_scan = getTableFromWidget(display) table_scan.save(path) # Force a workspace refresh on the new file ResourcesPlugin.getWorkspace().getRoot().getFileForLocation( Path(path)).refreshLocal(0, None)
def import_repo(): url = request.form['url'] name = request.form['name'] username = request.form.get("username") password = request.form.get("password") workspace = ResourcesPlugin.getWorkspace() root = workspace.root project = root.getProject(name) parts = urlparse.urlparse(url) try: svn_ops = SvnOperationFactory() if username is not None: svn_ops.authenticationManager = SVNWCUtil.createDefaultAuthenticationManager( username, password ) checkout = svn_ops.createCheckout() checkout.source = SvnTarget.fromURL(SVNURL.parseURIDecoded(url)) checkout.singleTarget = SvnTarget.fromFile(File(File(root.locationURI), name)) checkout.run() svn_ops.dispose() except Exception, e: return jsonify(status="err", error=str(e))
def page_not_found(e): workspace = ResourcesPlugin.getWorkspace() projects = get_projects(workspace) return render_template('404.html', workspace=workspace, projects=projects ), 404
def index(): workspace = ResourcesPlugin.getWorkspace() projects = get_projects(workspace) return render_template('index.html', workspace=workspace, projects=projects )
def run(self, monitor): global progress_monitor progress_monitor = monitor # workspace is org.eclipse.core.internal.resources.Workspace # http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IWorkspace.html workspace = ResourcesPlugin.getWorkspace() print workspace # root is org.eclipse.core.internal.resources.WorkspaceRoot root = workspace.getRoot() print root.__class__ # location will be IPath object, we need string presentation of the path # location = root.getRawLocation() path = location.toOSString() print "Importing egg omelette if there is one:" + path if self.import_omelette: omelette_path = import_omelette(root, path) print "Converting source folder to workspace projects:" + path # Convert Eclipse resource wrapper to readable file-system path #rootpath = Path(".") #file = root.getFileForLocation(rootpath) #print file for potential_folder in os.listdir(path): name = potential_folder potential_folder = os.path.join(path, potential_folder) # Make absolute if is_good_python_project(potential_folder): print "Importing:" + potential_folder project = import_folder_as_python_project(root, name, potential_folder, refer_to_omelette=self.import_omelette) else: print "Not a Python project:" + potential_folder # Check whether we can create instance laucher project = get_any_python_project(workspace) if project != None: create_instance_launcher(project) create_zope_debug_launcher(project) create_buildout_launcher() # Run Pain here workspace.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, progress_monitor) # This is a possible failing operation, run as the last download_ide_launcher(path) print "All done"
def project(project_name): workspace = ResourcesPlugin.getWorkspace() projects = get_projects(workspace) if project_name not in projects: abort(404) project = projects[project_name] return render_template('project.html', workspace=workspace, projects=projects, project=project )
def get_buildout_path(): """ @return: Path to buildout folder - assuming Eclipse is set up according to instructions """ # workspace is org.eclipse.core.internal.resources.Workspace # http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IWorkspace.html workspace = ResourcesPlugin.getWorkspace() root = workspace.getRoot() location = root.getRawLocation() path = location.toOSString() path = os.path.join(path, "..") path = os.path.normpath(path) return path
def search(): workspace = ResourcesPlugin.getWorkspace() projects = get_projects(workspace) files = get_all_files(projects) query = request.args['q'] found = [] for f in files: if query.lower() in f.toString().lower(): found.append(f) return render_template('search.html', workspace=workspace, projects=projects, matches=found, query=query )
def check_we_are_src(): """ Check whether workspace is set up according to instructions @return: False if this is not going to work """ workspace = ResourcesPlugin.getWorkspace() root = workspace.getRoot() location = root.getRawLocation() path = location.toOSString() if path.endswith("src") or path.endswith("products"): # products is a special case made for my Danish friend return True else: query = MessageDialog.openQuestion(window.getShell(), "Workspace is not correctly set up", "Workspace folder should be src/ folder of buildout. The current workspace folder '" + path + "' does not look like one. Scan checked out projects from this folder?") return query
def check_omelette(): """ @return: True if omelette is available and user would like to import it """ # workspace is org.eclipse.core.internal.resources.Workspace # http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IWorkspace.html workspace = ResourcesPlugin.getWorkspace() root = workspace.getRoot() # location will be IPath object, we need string presentation of the path # location = root.getRawLocation() path = location.toOSString() omelette_path = os.path.join(path, "..", "parts", "omelette") omelette_path = os.path.normpath(omelette_path) if os.path.exists(omelette_path): query = MessageDialog.openQuestion(window.getShell(), "Omelette detected", "Omelette buildout part contains all Python files used by Plone in symlinked structure. Importing omelette folder to workspace makes Python name completion to work. However, it is a very heavy task - loooong 'Building workspace' operation must be done when the workspace is refreshed. Unless you have a very powerful computer your computer will probably melt down to smoldering ashes. Alternatively toggle on 'Analyze open editors only' setting in PyDev preferences. Import omelette?") return query else: return False
def source(project_name, path): workspace = ResourcesPlugin.getWorkspace() projects = get_projects(workspace) if project_name not in projects: abort(404) project = projects[project_name] resource = project.project.findMember(Path(path)) if resource is None: abort(404) if resource.type == IResource.FILE: code = open(resource.contents).read().decode('utf-8', errors='replace').replace("\r", "") parser = ASTParser.newParser(AST.JLS3) parser.kind = ASTParser.K_COMPILATION_UNIT parser.setSource(String(code).toCharArray()) parser.resolveBindings = True comp_unit = parser.createAST(None) return render_template('file.html', workspace=workspace, projects=projects, comp_unit=comp_unit, project=project, code=code ) else: return render_template('folder.html', workspace=workspace, projects=projects, project=project, folder=resource )
def get_project_path(pname): return str(ResourcesPlugin.getWorkspace().getRoot().getProject(pname).getLocation().toString())
def getProject(name): javaProjects = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects() for project in javaProjects: if project.getProject().getDescription().getName() == name: return project
__script__ = Script(__model__) __script__.title = 'unknown' __script__.version = 'unknown' __runner__ = __UI__.getRunner() __writer__ = __UI__.getScriptExecutor().getEngine().getContext().getWriter() def logln(text): log(text, __writer__) clear = script.clear Par.__model__ = __model__ Act.__model__ = __model__ Group.__model__ = __model__ df = script.df Plot1 = GPlot(widget=__register__.getPlot1()) Plot2 = GPlot(widget=__register__.getPlot2()) Plot3 = GPlot(widget=__register__.getPlot3()) gumtree_root = str(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()) def noclose(): print 'not closable' def load_script(fname): fname = os.path.dirname(__UI__.getScriptFilename()) + '/' + fname __UI__.loadScript(fname) def confirm(msg): return __runner__.openConfirm(msg) def selectSaveFolder(): return __runner__.selectSaveFile() Plot1.close = noclose Plot2.close = noclose Plot3.close = noclose # Plot1 = Image(widget=__register__.getPlot1()) # Plot2 = Plot(widget=__register__.getPlot2()) # Plot3 = Image(widget=__register__.getPlot3())
def noclose(): print 'not closable' if __register__.getPlot1() != None: Plot1 = GPlot(widget=__register__.getPlot1()) Plot1.close = noclose if __register__.getPlot2() != None: Plot2 = GPlot(widget=__register__.getPlot2()) Plot2.close = noclose if __register__.getPlot3() != None: Plot3 = GPlot(widget=__register__.getPlot3()) Plot3.close = noclose gumtree_root = str( ResourcesPlugin.getWorkspace().getRoot().getLocation().toString()) def get_project_path(pname): return str(ResourcesPlugin.getWorkspace().getRoot().getProject( pname).getLocation().toString()) def get_absolute_path(spath): return str(ScriptControlViewer.getFullScriptPath(spath)) def load_script(fname): fname = os.path.dirname(__UI__.getScriptFilename()) + '/' + fname __UI__.loadScript(fname)
def get_project_path(pname): return str(ResourcesPlugin.getWorkspace().getRoot().getProject( pname).getLocation().toString())