mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Add printenv for linux (PY-15085)
This commit is contained in:
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Dumps environment variables into specified file.
|
||||
# Format: zero-separated "name=value" pairs in platform encoding.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
raise Exception('Exactly one argument expected')
|
||||
|
||||
f = open(sys.argv[1], 'wb')
|
||||
try:
|
||||
for key, value in os.environ.items():
|
||||
s = '%s=%s\0' % (key, value)
|
||||
f.write(s.encode('utf-8'))
|
||||
finally:
|
||||
f.close()
|
||||
@@ -161,10 +161,11 @@ public class EnvironmentUtil {
|
||||
public static class ShellEnvReader {
|
||||
|
||||
public Map<String, String> readShellEnv() throws Exception {
|
||||
String os = SystemInfo.isLinux ? "linux" : "mac";
|
||||
File reader = FileUtil.findFirstThatExist(
|
||||
PathManager.getBinPath() + "/printenv.py",
|
||||
PathManager.getHomePath() + "/community/bin/mac/printenv.py",
|
||||
PathManager.getHomePath() + "/bin/mac/printenv.py");
|
||||
PathManager.getHomePath() + "/community/bin/" + os + "/printenv.py",
|
||||
PathManager.getHomePath() + "/bin/" + os + "/printenv.py");
|
||||
if (reader == null) {
|
||||
throw new Exception("bin:" + PathManager.getBinPath());
|
||||
}
|
||||
@@ -185,7 +186,8 @@ public class EnvironmentUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected static Map<String, String> runProcessAndReadEnvs(@NotNull List<String> command, @NotNull File envFile, String lineSeparator) throws Exception {
|
||||
protected static Map<String, String> runProcessAndReadEnvs(@NotNull List<String> command, @NotNull File envFile, String lineSeparator)
|
||||
throws Exception {
|
||||
ProcessBuilder builder = new ProcessBuilder(command).redirectErrorStream(true);
|
||||
builder.environment().put(DISABLE_OMZ_AUTO_UPDATE, "true");
|
||||
Process process = builder.start();
|
||||
|
||||
Reference in New Issue
Block a user