Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature improve error msg #1214

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions OpenBCI_GUI/Extras.pde
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,34 @@ public boolean isElevationNeeded(String path) {
}
return result;
}
/**
* Determines if user is in elevated group (plugdev).
*
* @return <code>true</code> if user is in group plugdev, <code>false</code> otherwise.
*/
public boolean isInElevatedGroup() {
boolean result = true;
if (isLinux()) {
try {
String command = "groups";
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
InputStream stdIn = p.getInputStream();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stdIn));
String[] values = bufferedReader.readLine().split(" ");
for (int idx=0; idx<values.length; idx++) {
result = values[idx].equals("plugdev");
if (result) {
break;
}
}
} catch (Exception e) {
return false;
}
}
return result;
}

/**
* Determine if user has administrative privileges.
*
Expand Down
4 changes: 2 additions & 2 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ void delayedSetup() {
//Apply GUI-wide settings to front end at the end of setup
guiSettings.applySettings();

if (!isAdminUser() || isElevationNeeded()) {
outputError("OpenBCI_GUI: This application is not being run with Administrator access. This could limit the ability to connect to devices or read/write files.");
if (!isInElevatedGroup() && (!isAdminUser() || isElevationNeeded())) {
outputError("OpenBCI_GUI: This application is not being run with Administrator access or user is not member of plugdev group. This could limit the ability to connect to devices or read/write files.");
}
}

Expand Down