Skip to content

Commit

Permalink
V1.19.00
Browse files Browse the repository at this point in the history
  • Loading branch information
jgyates committed Jan 6, 2024
1 parent 17671b5 commit 498f03d
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions genmonlib/myplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def IsOSWindows():
def IsPlatformRaspberryPi(self, raise_on_errors=False):

try:
model = self.GetRaspberryPiModel(bForce = True)
if model != None and "raspberry" in model.lower():
return True

with open("/proc/cpuinfo", "r") as cpuinfo:
found = False
for line in cpuinfo:
Expand Down Expand Up @@ -195,6 +199,19 @@ def GetRaspberryPiTemp(self, ReturnFloat=False):
self.LogErrorLine("Error in GetRaspberryPiTemp: " + str(e1))
return DefaultReturn

# ------------ MyPlatform::GetRaspberryPiModel -----------------------------
def GetRaspberryPiModel(self, bForce = False):
try:
if bForce == False and not self.IsPlatformRaspberryPi():
return None

process = Popen(["cat", "/proc/device-tree/model"], stdout=PIPE)
output, _error = process.communicate()
if sys.version_info[0] >= 3:
output = output.decode("utf-8")
return str(output.rstrip("\x00"))
except Exception as e1:
return None
# ------------ MyPlatform::GetRaspberryPiInfo -------------------------------
def GetRaspberryPiInfo(self):

Expand All @@ -207,11 +224,8 @@ def GetRaspberryPiInfo(self):
{"CPU Temperature": self.GetRaspberryPiTemp(ReturnFloat=False)}
)
try:
process = Popen(["cat", "/proc/device-tree/model"], stdout=PIPE)
output, _error = process.communicate()
if sys.version_info[0] >= 3:
output = output.decode("utf-8")
PiInfo.append({"Pi Model": str(output).rstrip("\x00")})
model = self.GetRaspberryPiModel()
PiInfo.append({"Pi Model": model})
except:
pass
try:
Expand Down

0 comments on commit 498f03d

Please sign in to comment.