From 32c79b69568ee7a1095d43ea14c7de0d6ae67a25 Mon Sep 17 00:00:00 2001
From: Auke Klazema <klazema@astron.nl>
Date: Mon, 15 Apr 2019 16:40:06 +0000
Subject: [PATCH] SW-658: Add str encode to convert string to bytes in
 createFiles

---
 MAC/Deployment/data/StaticMetaData/createFiles | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/MAC/Deployment/data/StaticMetaData/createFiles b/MAC/Deployment/data/StaticMetaData/createFiles
index 65f8e576efa..339f64e3847 100755
--- a/MAC/Deployment/data/StaticMetaData/createFiles
+++ b/MAC/Deployment/data/StaticMetaData/createFiles
@@ -44,8 +44,8 @@ def findIPNumber(stationName):
         command = "hostname -i"
         output = Popen(command,shell=True, stdout=PIPE).stdout
         stdout = output.readlines()
-        outline = stdout[0].strip()
-        outwords = outline.split().decode("UTF-8")
+        outline = stdout[0].strip().decode("UTF-8")
+        outwords = outline.split()
         if (len(outwords) != 1):
             return "-1"
         else:
@@ -55,8 +55,8 @@ def findIPNumber(stationName):
         command = "getent hosts "+stationName+"C"
         output = Popen(command,shell=True, stdout=PIPE).stdout
         stdout = output.readlines()
-        outline = stdout[0].strip()
-        outwords = outline.split().decode("UTF-8")
+        outline = stdout[0].strip().decode("UTF-8")
+        outwords = outline.split()
         if (len(outwords) < 2):
             print("Could not find IP for station, assuming 10.150.1.1")
             return "10.150.1.1"
@@ -466,7 +466,7 @@ def createRSPDriverFile(resultDir, stationName, dataDir,int_local,is_Cobalt):
     RSPconfig = RSPconfig.replace(repl_str, ethport)
     
     outFile = os.open(dataDir+"/RSPDriver.conf.tmp", os.O_RDWR|os.O_CREAT|os.O_TRUNC)
-    os.write(outFile, RSPconfig)
+    os.write(outFile, RSPconfig.encode())
     os.close(outFile)
 
 
@@ -604,7 +604,7 @@ def createRSPDriverFile_Test(resultDir, stationName, dataDir, alias):
     RSPconfig = RSPconfig.replace(repl_str, ethport)
          
     outFile = os.open(dataDir+"/RSPDriver.conf.tmp", os.O_RDWR|os.O_CREAT|os.O_TRUNC)
-    os.write(outFile, RSPconfig)
+    os.write(outFile, RSPconfig.encode())
     os.close(outFile)
 
     # An ugly way to get rid of all lines in the template file that are not
@@ -693,7 +693,7 @@ def createTBBDriverFile(resultDir, stationName, dataDir):
     TBBconfig = TBBconfig.replace(repl_str, ethport)
 
     outFile = os.open(dataDir+"/TBBDriver.conf.tmp", os.O_RDWR|os.O_CREAT|os.O_TRUNC)
-    os.write(outFile, TBBconfig)
+    os.write(outFile, TBBconfig.encode())
     os.close(outFile)
     # An ugly way to get rid of all lines in the template file that are not
     # filled yet.
@@ -723,7 +723,7 @@ def createRemoteStationFile(resultDir, stationName, dataDir):
     RSconfig = RSconfig.replace("@AARTFAAC@",     Aartfaac)
 
     outFile = os.open(resultDir+"/RemoteStation.conf", os.O_RDWR|os.O_CREAT|os.O_TRUNC)
-    os.write(outFile, RSconfig)
+    os.write(outFile, RSconfig.encode())
     os.close(outFile)
 
 
@@ -839,7 +839,7 @@ def createHardwareMonitorFile(resultDir, stationName, dataDir, last_ip="3"):
     HWMconfig = HWMconfig.replace("@STATION@",   stationName.upper())
     HWMconfig = HWMconfig.replace("@IP_ENV_CONTR@", HWMip)
     outFile = os.open(resultDir+"/HardwareMonitor.conf", os.O_RDWR|os.O_CREAT|os.O_TRUNC)
-    os.write(outFile, HWMconfig)
+    os.write(outFile, HWMconfig.encode())
     os.close(outFile)
     
 
-- 
GitLab