#9 Gracefully finish esptool when port cannot be open
Merged 2 years ago by ksurma. Opened 2 years ago by ksurma.
rpms/ ksurma/esptool finish  into  rawhide

file added
+29
@@ -0,0 +1,29 @@ 

+ From 57bd869b64c4eeaaad74791b2f7795264561f06e Mon Sep 17 00:00:00 2001

+ From: Karolina Surma <ksurma@redhat.com>

+ Date: Thu, 9 Jun 2022 11:50:25 +0200

+ Subject: [PATCH] Gracefully finish esptool when device is not detected on

+  given port

+ 

+ Silence the traceback that was being printed in such cases,

+ provide a user-friendly message and finish the app with sys.exit()

+ instead.

+ ---

+  esptool/loader.py | 5 ++++-

+  1 file changed, 4 insertions(+), 1 deletion(-)

+ 

+ diff --git a/esptool/loader.py b/esptool/loader.py

+ index 2059ea39..a0334b58 100644

+ --- a/esptool/loader.py

+ +++ b/esptool/loader.py

+ @@ -243,7 +243,10 @@ def __init__(self, port=DEFAULT_PORT, baud=ESP_ROM_BAUD, trace_enabled=False):

+          self.stub_is_disabled = False

+  

+          if isinstance(port, str):

+ -            self._port = serial.serial_for_url(port)

+ +            try:

+ +                self._port = serial.serial_for_url(port)

+ +            except serial.serialutil.SerialException:

+ +                raise FatalError(f"Could not open {port}, the port doesn't exist")

+          else:

+              self._port = port

+          self._slip_reader = slip_reader(self._port, self.trace)

file modified
+9 -1
@@ -1,6 +1,6 @@ 

  Name:           esptool

  Version:        4.1

- Release:        2%{?dist}

+ Release:        3%{?dist}

  Summary:        A utility to communicate with the ROM bootloader in Espressif ESP8266 & ESP32

  

  License:        GPLv2+
@@ -12,6 +12,10 @@ 

  

  Provides:       %{name}.py = %{version}-%{release}

  

+ # Gracefully finish esptool when the port cannot be open

+ # Merged upstream: https://github.com/espressif/esptool/pull/751

+ Patch:          https://github.com/espressif/esptool/pull/751.patch

+ 

  %description

  %{name}.py A command line utility to communicate with the ROM bootloader in

  Espressif ESP8266 & ESP32 WiFi microcontroller. Allows flashing firmware,
@@ -58,6 +62,10 @@ 

  

  

  %changelog

+ * Tue Jun 21 2022 Karolina Surma <ksurma@redhat.com> - 4.1-3

+ - Gracefully finish esptool when port can't be open

+ Resolves: rhbz#2092910

+ 

  * Tue Jun 14 2022 Python Maint <python-maint@redhat.com> - 4.1-2

  - Rebuilt for Python 3.11

  

Backported upstream fix, so that our package doesn't trigger abrt when it shouldn't.

Build succeeded.

rebased onto 7bc0201

2 years ago

Build succeeded.

Pull-Request has been merged by ksurma

2 years ago
Metadata