6 def verify_provisioned(akt_info, conf):
8 stdout, stderr, retcode = run_subprocess([str(akt_info),
'--config', str(conf),
'--wait-until-provisioned'])
9 machine = platform.node()
10 if (b
'Device ID: ' not in stdout
or
11 b
'Primary ECU hardware ID: ' + machine.encode()
not in stdout
or
12 b
'Fetched metadata: yes' not in stdout):
13 print(
'Provisioning failed: ' + stderr.decode() + stdout.decode())
15 p = re.compile(
r'Device ID: ([a-z0-9-]*)\n')
16 m = p.search(stdout.decode())
17 if not m
or m.lastindex <= 0:
18 print(
'Device ID could not be read: ' + stderr.decode() + stdout.decode())
20 print(
'Device successfully provisioned with ID: ' + m.group(1))
24 def run_subprocess(command, **kwargs):
25 print(
'> Running {}'.format(
' '.join(command)))
26 proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
28 stdout, stderr = proc.communicate(timeout=60)
29 except subprocess.TimeoutExpired:
31 stdout, stderr = proc.communicate()
32 return stdout, stderr, proc.returncode