use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class Pep8ExternalAnnotator method doAnnotate.
@Nullable
@Override
public Results doAnnotate(State collectedInfo) {
if (collectedInfo == null)
return null;
ArrayList<String> options = Lists.newArrayList();
if (!collectedInfo.ignoredErrors.isEmpty()) {
options.add("--ignore=" + DEFAULT_IGNORED_ERRORS + "," + StringUtil.join(collectedInfo.ignoredErrors, ","));
}
if (collectedInfo.hangClosingBrackets) {
options.add("--hang-closing");
}
options.add("--max-line-length=" + collectedInfo.margin);
options.add("-");
GeneralCommandLine cmd = PythonHelper.PYCODESTYLE.newCommandLine(collectedInfo.interpreterPath, options);
ProcessOutput output = PySdkUtil.getProcessOutput(cmd, new File(collectedInfo.interpreterPath).getParent(), ImmutableMap.of("PYTHONBUFFERED", "1"), 10000, collectedInfo.fileText.getBytes(), false);
Results results = new Results(collectedInfo.level);
if (output.isTimeout()) {
LOG.info("Timeout running pycodestyle.py");
} else if (output.getStderrLines().isEmpty()) {
for (String line : output.getStdoutLines()) {
final Problem problem = parseProblem(line);
if (problem != null) {
results.problems.add(problem);
}
}
} else if (((ApplicationInfoImpl) ApplicationInfo.getInstance()).isEAP()) {
LOG.info("Error running pycodestyle.py: " + output.getStderr());
}
return results;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class PythonTask method createProcess.
/**
* @param env environment variables to be passed to process or null if nothing should be passed
*/
public ProcessHandler createProcess(@Nullable final Map<String, String> env) throws ExecutionException {
final GeneralCommandLine commandLine = createCommandLine();
if (env != null) {
commandLine.getEnvironment().putAll(env);
}
// To support UTF-8 output
PydevConsoleRunner.setCorrectStdOutEncoding(commandLine, myModule.getProject());
ProcessHandler handler;
if (PySdkUtil.isRemote(mySdk)) {
assert mySdk != null;
handler = new PyRemoteProcessStarter().startRemoteProcess(mySdk, commandLine, myModule.getProject(), null);
} else {
EncodingEnvironmentUtil.setLocaleEnvironmentIfMac(commandLine);
handler = PythonProcessRunner.createProcessHandlingCtrlC(commandLine);
ProcessTerminatedListener.attach(handler);
}
return handler;
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class StudyRunAction method executeFile.
private void executeFile(@NotNull final Project project, @NotNull final VirtualFile openedFile, @NotNull final String filePath) {
GeneralCommandLine cmd = new GeneralCommandLine();
cmd.withWorkDirectory(openedFile.getParent().getCanonicalPath());
TaskFile selectedTaskFile = StudyUtils.getTaskFile(project, openedFile);
assert selectedTaskFile != null;
final Task currentTask = selectedTaskFile.getTask();
final Sdk sdk = StudyUtils.findSdk(currentTask, project);
if (sdk == null) {
StudyUtils.showNoSdkNotification(currentTask, project);
return;
}
String sdkHomePath = sdk.getHomePath();
if (sdkHomePath != null) {
cmd.setExePath(sdkHomePath);
StudyUtils.setCommandLineParameters(cmd, project, filePath, sdkHomePath, currentTask);
try {
myHandler = new OSProcessHandler(cmd);
} catch (ExecutionException e) {
LOG.error(e);
return;
}
for (ProcessListener processListener : myProcessListeners) {
myHandler.addProcessListener(processListener);
}
final RunContentExecutor executor = StudyUtils.getExecutor(project, currentTask, myHandler);
if (executor != null) {
Disposer.register(project, executor);
executor.run();
}
EduUtils.synchronize();
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project intellij-community by JetBrains.
the class PyCondaManagementService method addRepository.
@Override
public void addRepository(String repositoryUrl) {
final String conda = PyCondaPackageService.getCondaExecutable(mySdk.getHomeDirectory());
final ArrayList<String> parameters = Lists.newArrayList(conda, "config", "--add", "channels", repositoryUrl, "--force");
final GeneralCommandLine commandLine = new GeneralCommandLine(parameters);
try {
final CapturingProcessHandler handler = new CapturingProcessHandler(commandLine);
final ProcessOutput result = handler.runProcess();
final int exitCode = result.getExitCode();
if (exitCode != 0) {
final String message = StringUtil.isEmptyOrSpaces(result.getStdout()) && StringUtil.isEmptyOrSpaces(result.getStderr()) ? "Permission denied" : "Non-zero exit code";
LOG.warn("Failed to add repository " + message);
}
PyCondaPackageService.getInstance().addChannel(repositoryUrl);
} catch (ExecutionException e) {
LOG.warn("Failed to add repository");
}
}
use of com.intellij.execution.configurations.GeneralCommandLine in project kotlin by JetBrains.
the class Emulator method getWaitCommand.
private GeneralCommandLine getWaitCommand() {
GeneralCommandLine commandLine = new GeneralCommandLine();
String adbCmdName = SystemInfo.isWindows ? "adb.exe" : "adb";
commandLine.setExePath(pathManager.getPlatformToolsFolderInAndroidSdk() + "/" + adbCmdName);
commandLine.addParameter("wait-for-device");
return commandLine;
}
Aggregations