diff --git a/armi/bookkeeping/report/reportingUtils.py b/armi/bookkeeping/report/reportingUtils.py index b1a2291b6..b14b13f24 100644 --- a/armi/bookkeeping/report/reportingUtils.py +++ b/armi/bookkeeping/report/reportingUtils.py @@ -283,6 +283,31 @@ def _getSystemInfoWindows(): return subprocess.run(cmd, capture_output=True, text=True, shell=True).stdout +def _getSystemInfoMac(): + """Get system information, assuming the system is MacOS. + + Returns + ------- + str + Basic system information: OS name, OS version, basic processor information + + Examples + -------- + Example results: + + System Software Overview: + + System Version: macOS 12.1 (21C52) + Kernel Version: Darwin 21.2.0 + ... + Hardware Overview: + Model Name: MacBook Pro + ... + """ + cmd = "system_profiler SPSoftwareDataType SPHardwareDataType" + return subprocess.run(cmd, capture_output=True, text=True, shell=True).stdout + + def _getSystemInfoLinux(): """Get system information, assuming the system is Linux. @@ -369,6 +394,8 @@ def getSystemInfo(): return _getSystemInfoWindows() elif "linux" in sys.platform: return _getSystemInfoLinux() + elif "darwin" in sys.platform: + return _getSystemInfoMac() else: runLog.warning( f"Cannot get system information for {sys.platform} because ARMI only " diff --git a/armi/bookkeeping/report/tests/test_report.py b/armi/bookkeeping/report/tests/test_report.py index 87298060e..28e396349 100644 --- a/armi/bookkeeping/report/tests/test_report.py +++ b/armi/bookkeeping/report/tests/test_report.py @@ -16,6 +16,7 @@ import logging import os import subprocess +import sys import unittest from unittest.mock import patch @@ -98,7 +99,12 @@ def test_getSystemInfo(self): to fail if the test is run on some other OS. """ out = getSystemInfo() - substrings = ["OS ", "Processor(s):"] + + if "darwin" in sys.platform: + substrings = ["System Software", "Hardware Overview"] + else: + substrings = ["OS ", "Processor(s):"] + for sstr in substrings: self.assertIn(sstr, out)