Skip to content

Commit

Permalink
notify the user about serial access
Browse files Browse the repository at this point in the history
  • Loading branch information
Iris-TheRainbow committed Sep 17, 2024
1 parent 500ad3d commit 25a3324
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion REVHubInterface/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
import os
import datetime
import traceback

import REVHubInterface.serialaccess as serialaccess
# try:
# import ft232
# except Exception as e:
# print(platform.system)
# 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))
if not serialaccess.hasAccess():
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.\nhttps://github.com/unofficial-rev-port/REVHubInterface/blob/main/README.md#access-to-serial-on-linux")

def error(windowName: str, error: Exception) -> None:
errName = str(error)
print(errName)
Expand Down
12 changes: 12 additions & 0 deletions REVHubInterface/serialaccess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import grp
import os, sys

def hasAccess():
if sys.platform == "linux":
try:
groups = [g.gr_name for g in grp.getgrall() if os.getlogin() in g.gr_mem]
if 'dialout' in groups or 'uucp' in groups: return True
return False
except KeyError:
return False
else: return True

0 comments on commit 25a3324

Please sign in to comment.