31
31
import csv
32
32
import os
33
33
import sys
34
- import signal
35
- from subprocess import call
36
34
import subprocess
37
35
import json
38
36
47
45
["Zen 3" , "Zen 4" ]]
48
46
49
47
50
- def signal_handler (sig , frame ):
51
- print ('You sent SIGINT signal, stoping docker compose stack' )
52
- call ("./stop.sh" )
53
-
54
-
55
48
def docker_start (time ):
49
+ """
50
+ Start the docker compose stack and the logs
51
+ :param time: The duration of the demo
52
+ """
56
53
id1 = os .popen ("id -u" ).read ()
57
54
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 :
59
56
for line in firstfile :
60
57
secondfile .write (line )
61
58
secondfile .write ("UID=" + id1 )
62
59
secondfile .write ("GUID=" + id2 )
63
-
64
- print ("docker compose up -d" )
65
60
os .system ("docker compose up -d" )
66
61
os .system ("docker compose logs sensor -f &" )
67
62
os .system ("docker compose logs formula -f &" )
@@ -70,10 +65,13 @@ def docker_start(time):
70
65
71
66
72
67
def docker_stop ():
68
+ """
69
+ Stop the docker compose stack and clean the environment
70
+ """
73
71
os .system ("set -ueo pipefail" )
74
72
os .system ("set +x" )
75
73
os .system ("docker compose down" )
76
- open ('.env' , 'w' ).close ()
74
+ open ('.env' , 'w' , encoding = 'UTF-8' ).close ()
77
75
78
76
79
77
def load_data ():
@@ -170,9 +168,9 @@ def find_cpu(data):
170
168
option = []
171
169
line = "cat /proc/cpuinfo | grep 'model name'"
172
170
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 ])
174
172
parse = parse_processor_name (result [0 ])
175
- for row in data :
173
+ for row in data :
176
174
if parse [0 ] in row ["Name" ] and row ["Manufacturer" ] == parse [1 ]:
177
175
option .append (row )
178
176
@@ -193,6 +191,11 @@ def find_cpu(data):
193
191
194
192
195
193
def 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
+ """
196
199
if "Intel" in name :
197
200
brand = "Intel"
198
201
elif "AMD" in name :
0 commit comments