From dff94f05d1d352da2a005fd020e406a7901e1256 Mon Sep 17 00:00:00 2001 From: dam1n19 <d.a.mapstone@soton.ac.uk> Date: Fri, 6 Jan 2023 18:41:14 +0000 Subject: [PATCH] platform support --- model/py/message_build.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/model/py/message_build.py b/model/py/message_build.py index f85dd8e..ef9f5dd 100644 --- a/model/py/message_build.py +++ b/model/py/message_build.py @@ -11,7 +11,7 @@ import os, sys, random, math, csv import subprocess -from hashlib import sha256 +import platform def main(): # Check Environment Variables set @@ -82,10 +82,14 @@ def main(): out_data_words_list += out_data_words out_data_words_last_list += out_data_words_last intval = int(data, 2) - cmd = f"echo -n {data} | shasum -a 256 -0" - hash_process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) - hash_val = (str(hash_process.communicate()[0]).split()[0][2:]) - # hash_val = subprocess.getoutput(["echo", "-n", data ,"|", "shasum", "-a", "256", "-0"]) + hash_val = 0 + if (platform.system() == "Darwin"): + cmd = f"echo -n {data} | shasum -a 256 -0" + hash_process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + hash_val = (str(hash_process.communicate()[0]).split()[0][2:]) + else: + print("Platform not supported yet") + exit() # print(hash_val) hash_list.append(hash_val) -- GitLab