Skip to content

Commit a970b51

Browse files
authored
Merge pull request #180 from Vodorok/py_purge
Purged virtual environment relations
2 parents bfac6b0 + a43dca8 commit a970b51

File tree

9 files changed

+27
-126
lines changed

9 files changed

+27
-126
lines changed

bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CcConfigurationBase.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,6 @@ public String get(ConfigTypes type) {
6464
return config.get(type);
6565
}
6666

67-
/**
68-
* @return True if the python values are set.
69-
*/
70-
public boolean isPythonConfigured() {
71-
return !(!config.containsKey(ConfigTypes.PYTHON_PATH)
72-
|| (config.containsKey(ConfigTypes.PYTHON_PATH) && config.get(ConfigTypes.PYTHON_PATH).isEmpty()));
73-
}
74-
7567
/**
7668
* Returns the default configuration for the plug-in.
7769
* @return An Unmodifiable view of the default configuration Map.

bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/CommonGui.java

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@
55
import java.util.List;
66
import java.util.Map;
77

8+
import org.codechecker.eclipse.plugin.Logger;
9+
import org.codechecker.eclipse.plugin.config.Config.ConfigTypes;
10+
import org.codechecker.eclipse.plugin.config.global.CcGlobalConfiguration;
11+
import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject;
12+
import org.codechecker.eclipse.plugin.itemselector.CheckerView;
13+
import org.codechecker.eclipse.plugin.runtime.CodeCheckEnvironmentChecker;
14+
import org.codechecker.eclipse.plugin.utils.CheckerItem;
15+
import org.codechecker.eclipse.plugin.utils.CheckerItem.LAST_ACTION;
816
import org.eclipse.core.resources.IProject;
917
import org.eclipse.core.runtime.IStatus;
1018
import org.eclipse.jface.action.Action;
1119
import org.eclipse.jface.dialogs.IMessageProvider;
1220
import org.eclipse.swt.SWT;
21+
import org.eclipse.swt.events.ModifyEvent;
22+
import org.eclipse.swt.events.ModifyListener;
1323
import org.eclipse.swt.events.SelectionAdapter;
1424
import org.eclipse.swt.events.SelectionEvent;
1525
import org.eclipse.swt.layout.GridData;
@@ -18,9 +28,7 @@
1828
import org.eclipse.swt.widgets.Composite;
1929
import org.eclipse.swt.widgets.Control;
2030
import org.eclipse.swt.widgets.DirectoryDialog;
21-
import org.eclipse.swt.widgets.Event;
2231
import org.eclipse.swt.widgets.Label;
23-
import org.eclipse.swt.widgets.Listener;
2432
import org.eclipse.swt.widgets.Shell;
2533
import org.eclipse.swt.widgets.Text;
2634
import org.eclipse.ui.IWorkbench;
@@ -30,14 +38,6 @@
3038
import org.eclipse.ui.forms.widgets.FormToolkit;
3139
import org.eclipse.ui.forms.widgets.ScrolledForm;
3240
import org.eclipse.ui.forms.widgets.Section;
33-
import org.codechecker.eclipse.plugin.Logger;
34-
import org.codechecker.eclipse.plugin.config.Config.ConfigTypes;
35-
import org.codechecker.eclipse.plugin.config.global.CcGlobalConfiguration;
36-
import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject;
37-
import org.codechecker.eclipse.plugin.itemselector.CheckerView;
38-
import org.codechecker.eclipse.plugin.runtime.CodeCheckEnvironmentChecker;
39-
import org.codechecker.eclipse.plugin.utils.CheckerItem;
40-
import org.codechecker.eclipse.plugin.utils.CheckerItem.LAST_ACTION;
4141

4242
/**
4343
* Global and project level preferences pages.
@@ -63,7 +63,7 @@ public class CommonGui {
6363
private CcConfigurationBase config;
6464
private CodeCheckerProject cCProject;
6565
private Text codeCheckerDirectoryField;// codechecker dir
66-
private Text pythonEnvField;// CodeChecker python env
66+
6767
private Text numThreads;// #of analysis threads
6868
private Text cLoggers;// #C compiler commands to catch
6969

@@ -151,9 +151,10 @@ public Control createContents(final Composite parent) {
151151
checkerConfigSection.setText("Configuration");
152152

153153
codeCheckerDirectoryField = addTextField(toolkit, client, "CodeChecker package root directory", "");
154-
codeCheckerDirectoryField.addListener(SWT.FocusOut, new Listener() {
154+
codeCheckerDirectoryField.addModifyListener(new ModifyListener() {
155+
155156
@Override
156-
public void handleEvent(Event event) {
157+
public void modifyText(ModifyEvent e) {
157158
try {
158159
Map<ConfigTypes, String> changedConfig = getConfigFromFields();
159160
CodeCheckEnvironmentChecker.getCheckerEnvironment(changedConfig,
@@ -187,21 +188,6 @@ public void widgetSelected(SelectionEvent event) {
187188
}
188189
});
189190

190-
pythonEnvField = addTextField(toolkit, client, "Python virtualenv root directory (optional)", "");
191-
final Button pythonEnvFieldBrowse = new Button(client, SWT.PUSH);
192-
pythonEnvFieldBrowse.setText(BROSWE);
193-
pythonEnvFieldBrowse.addSelectionListener(new SelectionAdapter() {
194-
public void widgetSelected(SelectionEvent event) {
195-
DirectoryDialog dlg = new DirectoryDialog(client.getShell());
196-
dlg.setFilterPath(codeCheckerDirectoryField.getText());
197-
dlg.setText("Browse python environment");
198-
String dir = dlg.open();
199-
if (dir != null) {
200-
pythonEnvField.setText(dir);
201-
}
202-
}
203-
});
204-
205191
numThreads = addTextField(toolkit, client, "Number of analysis threads", "4");
206192
toolkit.createLabel(client, "");
207193
cLoggers = addTextField(toolkit, client, "Compiler commands to log", "gcc:g++:clang:clang++");
@@ -371,7 +357,6 @@ public Map<ConfigTypes, String> loadConfig(boolean resetToDefault) {
371357
*/
372358
public void setFields(Map<ConfigTypes, String> config) {
373359
codeCheckerDirectoryField.setText(config.get(ConfigTypes.CHECKER_PATH));
374-
pythonEnvField.setText(config.get(ConfigTypes.PYTHON_PATH));
375360
checkerListArg = config.get(ConfigTypes.CHECKER_LIST);
376361
cLoggers.setText(config.get(ConfigTypes.COMPILERS));
377362
numThreads.setText(config.get(ConfigTypes.ANAL_THREADS));
@@ -384,7 +369,6 @@ public void setFields(Map<ConfigTypes, String> config) {
384369
public Map<ConfigTypes, String> getConfigFromFields() {
385370
Map<ConfigTypes, String> conf = new HashMap<>();
386371
conf.put(ConfigTypes.CHECKER_PATH, codeCheckerDirectoryField.getText());
387-
conf.put(ConfigTypes.PYTHON_PATH, pythonEnvField.getText());
388372
conf.put(ConfigTypes.CHECKER_LIST, checkerListArg);
389373
conf.put(ConfigTypes.ANAL_THREADS, numThreads.getText());
390374
conf.put(ConfigTypes.COMPILERS, cLoggers.getText());
@@ -397,7 +381,6 @@ public Map<ConfigTypes, String> getConfigFromFields() {
397381
public void saveConfig() {
398382
Map<ConfigTypes, String> conf = new HashMap<ConfigTypes, String>();
399383
conf.put(ConfigTypes.CHECKER_PATH, codeCheckerDirectoryField.getText());
400-
conf.put(ConfigTypes.PYTHON_PATH, pythonEnvField.getText());
401384
conf.put(ConfigTypes.CHECKER_LIST, checkerListArg);
402385
conf.put(ConfigTypes.ANAL_THREADS, numThreads.getText());
403386
conf.put(ConfigTypes.COMPILERS, cLoggers.getText());

bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/Config.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
import java.util.Map;
66
import java.util.Set;
77

8-
import org.eclipse.core.runtime.IStatus;
9-
108
import org.codechecker.eclipse.plugin.Logger;
9+
import org.eclipse.core.runtime.IStatus;
1110

1211
/**
1312
* Classes for handling actual configuration entries, and logging.
@@ -23,7 +22,6 @@ public class Config {
2322
public enum ConfigTypes {
2423
// Common configuration values
2524
CHECKER_PATH("codechecker_path"),
26-
PYTHON_PATH(""),
2725
COMPILERS("gcc:g++:clang:clang++"),
2826
ANAL_THREADS("4"),
2927
CHECKER_LIST("enabled_checkers"),

bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/EnvironmentVariables.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package org.codechecker.eclipse.plugin.config;
22

3-
import java.util.EnumSet;
4-
import java.util.Set;
5-
63
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
74

85
/**
@@ -14,14 +11,7 @@ public enum EnvironmentVariables {
1411
CC_LOGGER_GCC_LIKE("clang", IEnvironmentVariable.ENVVAR_REPLACE),
1512
LD_PRELOAD("ldlogger.so", IEnvironmentVariable.ENVVAR_REPLACE),
1613
CC_LOGGER_FILE("logfile", IEnvironmentVariable.ENVVAR_REPLACE),
17-
CC_LOGGER_BIN("/bin/ldlogger", IEnvironmentVariable.ENVVAR_REPLACE),
18-
//python variables comes after this;
19-
PATH("/bin:", IEnvironmentVariable.ENVVAR_PREPEND),
20-
VIRTUAL_ENV("pythonEnv", IEnvironmentVariable.ENVVAR_REPLACE);
21-
22-
public static Set<EnvironmentVariables> BASE_TYPE = EnumSet.range(LD_LIBRARY_PATH, CC_LOGGER_BIN);
23-
public static Set<EnvironmentVariables> PYTHON_TYPE = EnumSet.range(PATH, VIRTUAL_ENV);
24-
public static Set<EnvironmentVariables> ALL = EnumSet.range(LD_LIBRARY_PATH, VIRTUAL_ENV);
14+
CC_LOGGER_BIN("/bin/ldlogger", IEnvironmentVariable.ENVVAR_REPLACE);
2515

2616
private String defaultValue;
2717
private int method;

bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/config/project/CodeCheckerProject.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public void cleanUp() {
9090
*/
9191
private void setEnvironment() {
9292
//Initialize to defaults.
93-
for (EnvironmentVariables ev :EnvironmentVariables.BASE_TYPE) {
93+
for (EnvironmentVariables ev : EnvironmentVariables.values()) {
9494
environmentVariables.put(ev, ev.getDefaultValue());
9595
}
9696
String checkerDir = current.get(ConfigTypes.CHECKER_PATH);
@@ -107,14 +107,6 @@ private void setEnvironment() {
107107
Paths.get(codeCheckerWorkspace.toString(),
108108
COMPILATION_COMMANDS).toString());
109109

110-
if (current.isPythonConfigured()) {
111-
for (EnvironmentVariables ev :EnvironmentVariables.PYTHON_TYPE) {
112-
environmentVariables.put(ev, ev.getDefaultValue());
113-
}
114-
environmentVariables.put(EnvironmentVariables.PATH,
115-
current.get(ConfigTypes.PYTHON_PATH) + EnvironmentVariables.PATH.getDefaultValue());
116-
environmentVariables.put(EnvironmentVariables.VIRTUAL_ENV, current.get(ConfigTypes.PYTHON_PATH));
117-
}
118110
modifyProjectEnvironmentVariables();
119111
}
120112

bundles/org.codechecker.eclipse.plugin/src/org/codechecker/eclipse/plugin/runtime/CodeCheckEnvironmentChecker.java

Lines changed: 5 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@
44
import java.util.HashMap;
55
import java.util.Map;
66

7-
import org.codechecker.eclipse.plugin.Logger;
87
import org.codechecker.eclipse.plugin.config.Config.ConfigTypes;
98
import org.codechecker.eclipse.plugin.config.global.CcGlobalConfiguration;
109
import org.codechecker.eclipse.plugin.config.project.CodeCheckerProject;
1110
import org.eclipse.core.runtime.IProgressMonitor;
12-
import org.eclipse.core.runtime.IStatus;
1311

1412
import com.google.common.base.Optional;
15-
import com.google.common.collect.ImmutableMap;
1613

1714
/**
1815
* This class checks for Environments used by CodeChecker.
@@ -24,14 +21,12 @@ public class CodeCheckEnvironmentChecker {
2421

2522
private static final String HELP_ARGUMENT = "-h";
2623
private static final int WAIT_TIME_MULTIPLYER = 1000; // in milliseconds
24+
private static final Map<String, String> SYS_ENV = System.getenv();
2725

28-
public final Optional<String> pythonEnvironment;
2926
public final String checkerDir; // root directory of CodeChecker
3027
public final String codeCheckerCommand; // CodecCheker executable path
3128

32-
public final ImmutableMap<String, String> environmentBefore;
33-
34-
public Map<String, File> commandSubstitutionMap;
29+
private Map<String, File> commandSubstitutionMap;
3530

3631
private Map<ConfigTypes,String> config;
3732
private CodeCheckerProject project;
@@ -51,22 +46,10 @@ public CodeCheckEnvironmentChecker(CodeCheckerProject project) {
5146
else
5247
config = CcGlobalConfiguration.getInstance().get();
5348

54-
if (!config.containsKey(ConfigTypes.PYTHON_PATH)
55-
|| (config.containsKey(ConfigTypes.PYTHON_PATH) && config.get(ConfigTypes.PYTHON_PATH).isEmpty())){
56-
pythonEnvironment=Optional.absent();
57-
SLogger.log(LogI.INFO, "pythonenv is not set");
58-
}
59-
else{
60-
SLogger.log(LogI.INFO, "pythonenv is set to:" + config.get(ConfigTypes.PYTHON_PATH));
61-
pythonEnvironment=Optional.of(config.get(ConfigTypes.PYTHON_PATH));
62-
}
63-
6449
//checkerList=getConfigValue(ConfigTypes.CHECKER_LIST);
6550
checkerDir=getConfigValue(ConfigTypes.CHECKER_PATH);
66-
environmentBefore = getInitialEnvironment(pythonEnvironment);
6751
codeCheckerCommand = checkerDir+"/bin/CodeChecker";
6852

69-
7053
commandSubstitutionMap = new HashMap<String, File>() {{
7154
put("CC_BIN", new File(codeCheckerCommand));
7255
}};
@@ -105,8 +88,7 @@ private String getConfigValue(ConfigTypes key) {
10588
public static void getCheckerEnvironment(
10689
Map<ConfigTypes, String> config, String codeCheckerBinaryPath) {
10790

108-
ShellExecutorHelper she = new ShellExecutorHelper(
109-
getInitialEnvironment(Optional.of(config.get(ConfigTypes.PYTHON_PATH))));
91+
ShellExecutorHelper she = new ShellExecutorHelper(SYS_ENV);
11092

11193
String cmd = "'${CC_BINARY}' " + HELP_ARGUMENT;
11294
@SuppressWarnings("serial")
@@ -130,34 +112,6 @@ public static void getCheckerEnvironment(
130112
}
131113
}
132114

133-
/**
134-
* Returns new environment if using Python virtual environment or System env if not.
135-
* @param pythonEnvironment Path to Python virtual environment activator.
136-
* @return The environment to be used.
137-
*/
138-
private static ImmutableMap<String, String> getInitialEnvironment(Optional<String> pythonEnvironment) {
139-
if (pythonEnvironment.isPresent()) {
140-
ShellExecutorHelper she = new ShellExecutorHelper(System.getenv());
141-
File pyEnv = new File(pythonEnvironment.get() + "/bin/activate");
142-
String cmd = "source '${PY_ENV}' ; env";
143-
@SuppressWarnings("serial")
144-
Map<String, File> substitutionMap = new HashMap<String, File>() {{ put("PY_ENV", pyEnv); }};
145-
Optional<String> output = she.quickReturnOutput(cmd, substitutionMap);
146-
if (!output.isPresent()) {
147-
Logger.log(IStatus.ERROR, "Couldn't check the python environment!");
148-
throw new IllegalArgumentException("Couldn't check the given python environment!");
149-
} else {
150-
ImmutableMap<String, String> environment = (new EnvironmentParser()).parse(output
151-
.get());
152-
return environment;
153-
}
154-
155-
} else {
156-
SLogger.log(LogI.INFO, "Python Env not specified. Using original system env.");
157-
return ImmutableMap.copyOf(System.getenv());
158-
}
159-
}
160-
161115
@Override
162116
public boolean equals(Object obj) {
163117
if (obj == null) return false;
@@ -194,7 +148,7 @@ public String createAnalyzeCommmand(String buildLog) {
194148
* @return CodeChecker check command output
195149
*/
196150
public String processLog(String buildLog, boolean logToConsole, IProgressMonitor monitor, int taskCount) {
197-
ShellExecutorHelper she = new ShellExecutorHelper(environmentBefore);
151+
ShellExecutorHelper she = new ShellExecutorHelper(SYS_ENV);
198152
String cmd = createAnalyzeCommmand(buildLog);
199153
SLogger.log(LogI.INFO, "SERVER_SER_MSG >> processLog >> "+ cmd);
200154
Optional<String> ccOutput = she.progressableWaitReturnOutput(cmd, commandSubstitutionMap, logToConsole, monitor, taskCount);
@@ -213,7 +167,7 @@ public String processLog(String buildLog, boolean logToConsole, IProgressMonitor
213167
* @return A String containing the checkers. One at a line.
214168
*/
215169
public String getCheckerList() {
216-
ShellExecutorHelper she = new ShellExecutorHelper(environmentBefore);
170+
ShellExecutorHelper she = new ShellExecutorHelper(SYS_ENV);
217171
String cmd = "'${CC_BIN}' checkers";
218172
Optional<String> ccOutput = she.waitReturnOutput(cmd, commandSubstitutionMap, false);
219173
return ccOutput.or("");

readme.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Run `mvn -f mavendeps/pom.xml p2:site && mvn clean verify` in the root of the pr
2929
Make sure that before staring Eclipse:
3030

3131
* CodeChecker/bin directory is included in PATH (e.g.: `export PATH="/home/<username>/CodeChecker/bin/:$PATH"`)
32-
* Python virtualenv with CodeChecker dependencies is sourced (e.g.: `source /home/<username>/venv/bin/activate`)
3332

3433
__Currently the plugin is only usable with a CDT project.__
3534

tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/IndicatorTest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
99
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel;
1010
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
11-
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
1211
import org.hamcrest.core.IsNull;
1312
import org.junit.Before;
1413
import org.junit.BeforeClass;
@@ -74,13 +73,7 @@ public void testNoCodeCheckerFound() {
7473
@Test
7574
public void testCodeCheckerFound() {
7675
Path ccDir = Utils.prepareCodeChecker();
77-
78-
SWTBotText text = bot.textWithLabel("CodeChecker package root directory");
79-
text.setText(ccDir.toString());
80-
text.setFocus();
81-
bot.textWithLabel("Python virtualenv root directory (optional)").setFocus();
82-
83-
bot.sleep(SHORT_WAIT_TIME);
76+
GuiUtils.setCCBinDir(ccDir, bot);
8477

8578
SWTBotCLabel label = null;
8679
try {

tests/org.codechecker.eclipse.rcp.it.tests/src/org/codechecker/eclipse/plugin/utils/GuiUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public final class GuiUtils {
4444
public static final String ENVIR_LOGGER_BIN = "CC_LOGGER_BIN";
4545
public static final String ENVIR_LOGGER_FILE = "CC_LOGGER_FILE";
4646
public static final String LDOGGER = "ldlogger";
47-
public static final String PY_DIR_WIDGET = "Python virtualenv root directory (optional)";
47+
public static final String THREAD_WIDGET = "Number of analysis threads";
4848
public static final String GLOBAL_RADIO = "Use global configuration";
4949
public static final String PROJECT_RADIO = "Use project configuration";
5050

@@ -110,10 +110,10 @@ public static void applyCloseProperties(SWTBotShell propertiesShell, SWTWorkbenc
110110
public static void setCCBinDir(Path ccDir, SWTWorkbenchBot bot) {
111111
SWTBotText text = bot.textWithLabel(GuiUtils.CC_DIR_WIDGET);
112112
text.setText(ccDir.toString());
113-
text.setFocus();
114-
bot.textWithLabel(GuiUtils.PY_DIR_WIDGET).setFocus();
113+
// text.setFocus();
114+
// bot.textWithLabel(THREAD_WIDGET).setFocus();
115115

116-
bot.sleep(SHORT_WAIT_TIME);
116+
// bot.sleep(SHORT_WAIT_TIME);
117117
}
118118

119119
/**

0 commit comments

Comments
 (0)