@Nullable @Override protected String getHelperPath(String helper) throws ExecutionException { final Sdk sdk = getSdk(); final SdkAdditionalData sdkData = sdk.getSdkAdditionalData(); if (sdkData instanceof PyRemoteSdkAdditionalDataBase) { final PyRemoteSdkAdditionalDataBase remoteSdkData = (PyRemoteSdkAdditionalDataBase) sdkData; try { String helpersPath; if (CaseCollector.useRemoteCredentials(remoteSdkData)) { final RemoteSdkCredentials remoteSdkCredentials = remoteSdkData.getRemoteSdkCredentials(false); helpersPath = remoteSdkCredentials.getHelpersPath(); } else { helpersPath = remoteSdkData.getHelpersPath(); } if (!StringUtil.isEmpty(helpersPath)) { return new RemoteFile(helpersPath, helper).getPath(); } else { return null; } } catch (InterruptedException e) { LOG.error(e); } catch (ExecutionException e) { throw analyzeException(e, helper, Collections.<String>emptyList()); } } return null; }
private Process createRemoteConsoleProcess( PythonRemoteInterpreterManager manager, String[] command, Map<String, String> env) throws ExecutionException { PyRemoteSdkAdditionalDataBase data = (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData(); assert data != null; GeneralCommandLine commandLine = new GeneralCommandLine(command); commandLine.getEnvironment().putAll(env); commandLine .getParametersList() .set( 1, PythonRemoteInterpreterManager.toSystemDependent( new File(data.getHelpersPath(), PYDEV_PYDEVCONSOLE_PY).getPath(), PySourcePosition.isWindowsPath(data.getInterpreterPath()))); commandLine.getParametersList().set(2, "0"); commandLine.getParametersList().set(3, "0"); myCommandLine = commandLine.getCommandLineString(); try { myRemoteCredentials = data.getRemoteSdkCredentials(true); PathMappingSettings mappings = manager.setupMappings(getProject(), data, null); RemoteSshProcess remoteProcess = manager.createRemoteProcess( getProject(), myRemoteCredentials, mappings, commandLine, true); Couple<Integer> remotePorts = getRemotePortsFromProcess(remoteProcess); remoteProcess.addLocalTunnel(myPorts[0], myRemoteCredentials.getHost(), remotePorts.first); remoteProcess.addRemoteTunnel(remotePorts.second, "localhost", myPorts[1]); myPydevConsoleCommunication = new PydevRemoteConsoleCommunication(getProject(), myPorts[0], remoteProcess, myPorts[1]); return remoteProcess; } catch (Exception e) { throw new ExecutionException(e.getMessage()); } }
@Override protected VirtualFile[] doAddItems() { Project project = CommonDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext(myPanel)); try { String[] files = PythonRemoteInterpreterManager.getInstance() .chooseRemoteFiles( project, (PyRemoteSdkAdditionalDataBase) mySdk.getSdkAdditionalData(), false); final String sourcesLocalPath = PySdkUtil.getRemoteSourcesLocalPath(mySdk.getHomePath()); VirtualFile[] vFiles = new VirtualFile[files.length]; int i = 0; for (String file : files) { String localRoot = PyRemoteSourceItem.localPathForRemoteRoot(sourcesLocalPath, file); myNewMappings.add(new PathMappingSettings.PathMapping(localRoot, file)); myRemoteSdkData.getPathMappings().addMappingCheckUnique(localRoot, file); if (!new File(localRoot).exists()) { new File(localRoot).mkdirs(); } vFiles[i++] = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(localRoot)); } vFiles = adjustAddedFileSet(myPanel, vFiles); List<VirtualFile> added = new ArrayList<VirtualFile>(vFiles.length); for (VirtualFile vFile : vFiles) { if (addElement(vFile)) { added.add(vFile); } } return VfsUtilCore.toVirtualFileArray(added); } catch (Exception e) { LOG.error(e); } return new VirtualFile[0]; }
@Override protected String getPresentablePath(VirtualFile value) { String path = value.getPath(); return myRemoteSdkData.getPathMappings().convertToRemote(path); }