Skip to content

Commit 125438b

Browse files
committed
2 parents ecbab51 + 8803c6a commit 125438b

File tree

4 files changed

+26
-46
lines changed

4 files changed

+26
-46
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ Alternately, you can download it from PyPi:
3232
2. Run `pip install REVHubInterface` to install
3333
3. Finally, run `python3 -m REVHubInterface` to run the app (it should also be runnable as `revhubinterface`)
3434

35+
## Access to serial on Linux
3536
To avoid needing to run REV Hub Interface with root privileges on Linux, add your user to the `dialout` group:
3637

37-
1. Run ```sudo usermod `whoami` -a -G dialout``` (on Arch Linux, you need to use `uucp` instead of `dialout`)
38+
1. this can be done with ```sudo usermod $USER -a -G dialout``` (on Arch Linux, you need to use `uucp` instead of `dialout`)
3839
2. Reboot
3940

4041

REVHubInterface/__main__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,21 @@
99
import os
1010
import datetime
1111
import traceback
12-
12+
import REVHubInterface.serialaccess as serialaccess
13+
import webbrowser
1314
# try:
1415
# import ft232
1516
# except Exception as e:
1617
# print(platform.system)
1718
# tkinter.messagebox.showerror('Drivers Not Detected', 'Please verify the correct drivers are installed. Without the correct dirvers, firmware update functionality will be unavailable.\n\n - Windows 10 and above should automatically install the correct drivers when the Expansion Hub is plugged in.\n\n - Windows 7 requires a manual install. Please see this link for the correct driver (FTDI D2xx): https://www.ftdichip.com/Drivers/CDM/CDM21228_Setup.zip\n\n - On macOS, install libftdi via Homebrew: "brew install libftdi"\n\n - On Linux, install libftdi. On Debian/Ubuntu-based systems, install it via "sudo apt install libftdi1"\n\nException Message:\n' + str(e))
19+
if not serialaccess.hasAccess():
20+
result = tkinter.messagebox.showerror("User does not have serial access", "Your user does not have access to serial. Switch to a user that does, or add your user to a group that has serial access.\nPress OK to open a link with instructions.")
21+
22+
if result == "ok":
23+
webbrowser.open("https://github.com/unofficial-rev-port/REVHubInterface/blob/main/README.md#access-to-serial-on-linux")
24+
exit(1)
25+
26+
1827
def error(windowName: str, error: Exception) -> None:
1928
errName = str(error)
2029
print(errName)

REVHubInterface/__main__.spec

Lines changed: 0 additions & 44 deletions
This file was deleted.

REVHubInterface/serialaccess.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import grp
2+
import getpass
3+
import sys
4+
5+
def hasAccess():
6+
if sys.platform == "linux":
7+
try:
8+
user = getpass.getuser() # Alternative to os.getlogin()
9+
groups = [g.gr_name for g in grp.getgrall() if user in g.gr_mem]
10+
if 'dialout' in groups or 'uucp' in groups: return True
11+
return False
12+
except KeyError:
13+
return False
14+
else: return True

0 commit comments

Comments
 (0)