3131import csv
3232import os
3333import sys
34- import signal
35- from subprocess import call
3634import subprocess
3735import json
3836
4745 ["Zen 3" , "Zen 4" ]]
4846
4947
50- def signal_handler (sig , frame ):
51- print ('You sent SIGINT signal, stoping docker compose stack' )
52- call ("./stop.sh" )
53-
54-
5548def docker_start (time ):
49+ """
50+ Start the docker compose stack and the logs
51+ :param time: The duration of the demo
52+ """
5653 id1 = os .popen ("id -u" ).read ()
5754 id2 = os .popen ("id -g" ).read ()
58- with open ('env_template' , 'r' ) as firstfile , open ('.env' , 'a' ) as secondfile :
55+ with open ('env_template' , 'r' , encoding = 'UTF-8' ) as firstfile , open ('.env' , 'a' , encoding = 'UTF-8 ' ) as secondfile :
5956 for line in firstfile :
6057 secondfile .write (line )
6158 secondfile .write ("UID=" + id1 )
6259 secondfile .write ("GUID=" + id2 )
63-
64- print ("docker compose up -d" )
6560 os .system ("docker compose up -d" )
6661 os .system ("docker compose logs sensor -f &" )
6762 os .system ("docker compose logs formula -f &" )
@@ -70,10 +65,13 @@ def docker_start(time):
7065
7166
7267def docker_stop ():
68+ """
69+ Stop the docker compose stack and clean the environment
70+ """
7371 os .system ("set -ueo pipefail" )
7472 os .system ("set +x" )
7573 os .system ("docker compose down" )
76- open ('.env' , 'w' ).close ()
74+ open ('.env' , 'w' , encoding = 'UTF-8' ).close ()
7775
7876
7977def load_data ():
@@ -170,9 +168,9 @@ def find_cpu(data):
170168 option = []
171169 line = "cat /proc/cpuinfo | grep 'model name'"
172170 result = subprocess .check_output (line , shell = True , text = True ).split ("\n " )
173- print ("The CPU found is" + result [0 ].split (":" )[1 ] )
171+ print ("The CPU found is" + result [0 ].split (":" )[1 ])
174172 parse = parse_processor_name (result [0 ])
175- for row in data :
173+ for row in data :
176174 if parse [0 ] in row ["Name" ] and row ["Manufacturer" ] == parse [1 ]:
177175 option .append (row )
178176
@@ -193,6 +191,11 @@ def find_cpu(data):
193191
194192
195193def parse_processor_name (name ):
194+ """
195+ Parse the processor name to extract the id and the brand
196+ :param name: Name of the processor, extracted from /proc/cpuinfo
197+ :return: id adn brand of the processor
198+ """
196199 if "Intel" in name :
197200 brand = "Intel"
198201 elif "AMD" in name :
0 commit comments