From f046c567c79344099017e5ad8d2902e703c89c0c Mon Sep 17 00:00:00 2001 From: Craig Warren Date: Tue, 28 Feb 2017 11:30:22 +0000 Subject: [PATCH] Further update to Linux exception handling for host info. --- gprMax/utilities.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gprMax/utilities.py b/gprMax/utilities.py index 8f3fc303..f9a0dd0f 100644 --- a/gprMax/utilities.py +++ b/gprMax/utilities.py @@ -211,11 +211,10 @@ def get_host_info(): # Linux elif sys.platform == 'linux': try: - manufacturer = subprocess.check_output("cat /sys/class/dmi/id/sys_vendor", shell=True).decode('utf-8').strip() - model = subprocess.check_output("cat /sys/class/dmi/id/product_name", shell=True).decode('utf-8').strip() + manufacturer = subprocess.check_output("cat /sys/class/dmi/id/sys_vendor", shell=True, stderr=subprocess.STDOUT).decode('utf-8').strip() + model = subprocess.check_output("cat /sys/class/dmi/id/product_name", shell=True, stderr=subprocess.STDOUT).decode('utf-8').strip() machineID = manufacturer + ' ' + model - except subprocess.CalledProcessError as e: - print(e.returncode) + except subprocess.CalledProcessError: machineID = 'unknown' # CPU information @@ -223,6 +222,8 @@ def get_host_info(): for line in allcpuinfo.split('\n'): if re.search('Model name', line): cpuID = re.sub('.*Model name.*:', '', line, 1).strip() + else: + cpuID = 'unknown' if 'Thread(s) per core' in line: threadspercore = int(line.strip()[-1]) if 'Socket(s)' in line: