diff --git a/commstat.py b/commstat.py index bd1e045..5566921 100644 --- a/commstat.py +++ b/commstat.py @@ -443,18 +443,22 @@ def oscheck(self): pios = "aarch64" winos = "Windows" linuxos = "Linux" + macos = "macOS" if pios in (platform.platform()): print("Commstat this is Pi 64bit OS") OS = "pi" bull1 = 0 bull2 = 4 - if winos in (platform.platform()): + elif winos in (platform.platform()): print("Commstat this is Windows OS") OS_Directed = "\DIRECTED.TXT" # sudo apt install ./python-pyqt5.qtwebengine_5.15.2-2_arm64.deb - if linuxos in (platform.platform()): + elif linuxos in (platform.platform()): print("Commstat this is Linux OS") OS_Directed = "/DIRECTED.TXT" + elif macos in (platform.platform()): + print("Commstat this is MacOS") + OS_Directed = "/DIRECTED.TXT" else: # print("This is not 64bit PiOS") @@ -813,7 +817,7 @@ def directedpi(self): def directed(self): global directedcounter - with open(path) as f, open('output.txt', 'w') as fout: + with open(path, 'r', encoding='utf-8', errors='ignore') as f, open('output.txt', 'w') as fout: fout.writelines(reversed(f.readlines())) text = open('output.txt').read() text_edit_widget = QPlainTextEdit(text) diff --git a/datareader.py b/datareader.py index 56007a6..d384ac1 100644 --- a/datareader.py +++ b/datareader.py @@ -64,18 +64,23 @@ def oscheck(): pios = "aarch64" winos = "Windows" linuxos = "Linux" + macos = "macOS" + if pios in (platform.platform()): print("Datareader this is Pi 64bit OS") OS = "pi" bull1 = 0 bull2 = 4 - if winos in (platform.platform()): + elif winos in (platform.platform()): print("Datareader this is Windows OS") OS_Directed = "\DIRECTED.TXT" # sudo apt install ./python-pyqt5.qtwebengine_5.15.2-2_arm64.deb - if linuxos in (platform.platform()): + elif linuxos in (platform.platform()): print("Datareader this is Linux OS") OS_Directed = "/DIRECTED.TXT" + elif macos in (platform.platform()): + print("Datareader this is macOS") + OS_Directed = "/DIRECTED.TXT" else: # print("This is not 64bit PiOS") @@ -124,7 +129,7 @@ def parseDirected(): conn = sqlite3.connect("traffic.db3") cur = conn.cursor() - datafile = open("copyDIRECTED.TXT", "r") + datafile = open("copyDIRECTED.TXT", "r",encoding='utf-8', errors='ignore') lines = datafile.readlines() last_lines = lines[-50:] for num, str1 in enumerate(last_lines, 1): diff --git a/install.py b/install.py index 28068ab..03f6cdd 100644 --- a/install.py +++ b/install.py @@ -17,6 +17,7 @@ def oscheck(): pios = "aarch64" lin = "Linux" win = "Windows" + mac = "macOS" if pios in (platform.platform()): print("This is Pi 64bit OS") osver = "pi" @@ -38,6 +39,10 @@ def oscheck(): print("This is Windows") osver = win test_python() + elif mac in (platform.platform()): + osver = mac + print("This is macOS") + test_python() else: print("Commstat does not recognize this operating system and cannot proceed.") return @@ -88,6 +93,9 @@ def test_python(): elif "pi" or "Linux" in osver: print("Installing for Linux Mint 20-21 Mate or Pi4 Bullseye 64bit") lininstall() + elif "macOS" in osver: + print("Installing for macOS") + macinstall() else: print("system not recognized") @@ -127,6 +135,13 @@ def wininstall(): install(seventhmodule) runsettings() +def macinstall(): + modules = ["pyqt5", "PyQtWebEngine", "feedparser", "file-read-backwards", "folium", "pandas", "maidenhead","psutil"] + for module in modules: + install(module) + runsettings() + + oscheck() diff --git a/netmanager.py b/netmanager.py index 7ebcee3..52a51dc 100644 --- a/netmanager.py +++ b/netmanager.py @@ -11,6 +11,7 @@ from configparser import ConfigParser import re from time import strftime +from webbrowser import MacOSXOSAScript from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtCore import QDateTime, Qt, QDate from PyQt5.QtWidgets import QMessageBox @@ -493,16 +494,20 @@ def oscheck(self): pios = "aarch64" winos = "Windows" linuxos = "Linux" + macos = "macOS" if pios in (platform.platform()): #print("Commstat this is Pi 64bit OS") OS = "pi" bull1 = 0 bull2 = 4 - if winos in (platform.platform()): + elif winos in (platform.platform()): #print("Commstat this is Windows OS") OS_Reports = "reports\\" # sudo apt install ./python-pyqt5.qtwebengine_5.15.2-2_arm64.deb - if linuxos in (platform.platform()): + elif linuxos in (platform.platform()): + #print("Commstat this is Linux OS") + OS_Reports = "reports/" + elif macos in (platform.platform()): #print("Commstat this is Linux OS") OS_Reports = "reports/" diff --git a/settings.py b/settings.py index f78a31c..c7fb40a 100644 --- a/settings.py +++ b/settings.py @@ -459,19 +459,23 @@ def oscheck(self): pios = "aarch64" winos = "Windows" linuxos = "Linux" + macos = "macOS" + if pios in (platform.platform()): print("This is Pi 64bit OS") OS = "pi" bull1 = 0 bull2 = 4 - if winos in (platform.platform()): + elif winos in (platform.platform()): print("This is Windows OS") OS_Directed = "\DIRECTED.TXT" # sudo apt install ./python-pyqt5.qtwebengine_5.15.2-2_arm64.deb - if linuxos in (platform.platform()): + elif linuxos in (platform.platform()): print("This is Linux OS") OS_Directed = "/DIRECTED.TXT" - + elif macos in (platform.platform()): + print("This is macOS") + OS_Directed = "/DIRECTED.TXT" else: # print("This is not 64bit PiOS") # OS = "Mint" @@ -615,6 +619,8 @@ def setInfo(self): path_to_file = (path+""+OS_Directed) + print(path_to_file) + if not os.path.exists(path_to_file): msg = QMessageBox() msg.setWindowTitle("CommStatX error")