|
@@ -3,8 +3,10 @@
|
|
|
import os
|
|
import os
|
|
|
import sys
|
|
import sys
|
|
|
import time
|
|
import time
|
|
|
|
|
+import copy
|
|
|
import serial
|
|
import serial
|
|
|
import tempfile
|
|
import tempfile
|
|
|
|
|
+import collections
|
|
|
from threading import Thread
|
|
from threading import Thread
|
|
|
import subprocess
|
|
import subprocess
|
|
|
import asyncio
|
|
import asyncio
|
|
@@ -50,6 +52,23 @@ def save_json(file, data):
|
|
|
print("Error: Data can't be serialized to json file!")
|
|
print("Error: Data can't be serialized to json file!")
|
|
|
return False
|
|
return False
|
|
|
|
|
|
|
|
|
|
+# get from https://gist.github.com/angstwad/bf22d1822c38a92ec0a9
|
|
|
|
|
+def dict_merge(dct, merge_dct):
|
|
|
|
|
+ """ Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
|
|
|
|
|
+ updating only top-level keys, dict_merge recurses down into dicts nested
|
|
|
|
|
+ to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
|
|
|
|
|
+ ``dct``.
|
|
|
|
|
+ :param dct: dict onto which the merge is executed
|
|
|
|
|
+ :param merge_dct: dct merged into dct
|
|
|
|
|
+ :return: None
|
|
|
|
|
+ """
|
|
|
|
|
+ for k, v in merge_dct.items():
|
|
|
|
|
+ if (k in dct and isinstance(dct[k], dict)
|
|
|
|
|
+ and isinstance(merge_dct[k], collections.Mapping)):
|
|
|
|
|
+ dict_merge(dct[k], merge_dct[k])
|
|
|
|
|
+ else:
|
|
|
|
|
+ dct[k] = merge_dct[k]
|
|
|
|
|
+
|
|
|
def get_make_csv(app, config):
|
|
def get_make_csv(app, config):
|
|
|
make_options = " "
|
|
make_options = " "
|
|
|
SUPPORT_KEYS = ["SOC", "BOARD", "CORE", "DOWNLOAD", "VARIANT", \
|
|
SUPPORT_KEYS = ["SOC", "BOARD", "CORE", "DOWNLOAD", "VARIANT", \
|
|
@@ -86,7 +105,7 @@ COMMAND_TIMEOUT=6
|
|
|
RUNSTATUS_OK=0
|
|
RUNSTATUS_OK=0
|
|
|
RUNSTATUS_FAIL=1
|
|
RUNSTATUS_FAIL=1
|
|
|
RUNSTATUS_NOTSTART=2
|
|
RUNSTATUS_NOTSTART=2
|
|
|
-def run_command(command, show_output=True, logfile=None):
|
|
|
|
|
|
|
+def run_command(command, show_output=True, logfile=None, append=False):
|
|
|
logfh = None
|
|
logfh = None
|
|
|
ret = COMMAND_RUNOK
|
|
ret = COMMAND_RUNOK
|
|
|
cmd_elapsed_ticks = 0
|
|
cmd_elapsed_ticks = 0
|
|
@@ -96,7 +115,10 @@ def run_command(command, show_output=True, logfile=None):
|
|
|
process = None
|
|
process = None
|
|
|
try:
|
|
try:
|
|
|
if isinstance(logfile, str):
|
|
if isinstance(logfile, str):
|
|
|
- logfh = open(logfile, "wb")
|
|
|
|
|
|
|
+ if append:
|
|
|
|
|
+ logfh = open(logfile, "ab")
|
|
|
|
|
+ else:
|
|
|
|
|
+ logfh = open(logfile, "wb")
|
|
|
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, \
|
|
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, \
|
|
|
stderr=subprocess.STDOUT)
|
|
stderr=subprocess.STDOUT)
|
|
|
while True:
|
|
while True:
|