Selaa lähdekoodia

Merge branch 'bugfix/log-error-run-esptool_v4.1' into 'release/v4.1'

parttool.py: Add file stream parameter and log stdout and stderr to same stream (v4.1)

See merge request espressif/esp-idf!10517
Ivan Grokhotkov 5 vuotta sitten
vanhempi
sitoutus
77be96fd87
1 muutettua tiedostoa jossa 9 lisäystä ja 2 poistoa
  1. 9 2
      components/partition_table/parttool.py

+ 9 - 2
components/partition_table/parttool.py

@@ -117,6 +117,9 @@ class ParttoolTarget():
 
 
         self.partition_table = partition_table
         self.partition_table = partition_table
 
 
+    # set `out` to None to redirect the output to the STDOUT
+    # otherwise set `out` to file descriptor
+    # beware that the method does not close the file descriptor
     def _call_esptool(self, args, out=None):
     def _call_esptool(self, args, out=None):
         esptool_args = [sys.executable, ESPTOOL_PY] + self.esptool_args
         esptool_args = [sys.executable, ESPTOOL_PY] + self.esptool_args
 
 
@@ -128,8 +131,12 @@ class ParttoolTarget():
 
 
         esptool_args += args
         esptool_args += args
 
 
-        with open(os.devnull, "w") as null_file:
-            subprocess.check_call(esptool_args, stdout=null_file, stderr=null_file)
+        print("Running %s..." % (" ".join(esptool_args)))
+        try:
+            subprocess.check_call(esptool_args, stdout=out, stderr=subprocess.STDOUT)
+        except subprocess.CalledProcessError as e:
+            print("An exception: **", str(e), "** occurred in _call_esptool.", file=out)
+            raise e
 
 
     def get_partition_info(self, partition_id):
     def get_partition_info(self, partition_id):
         partition = None
         partition = None