From 59ced98d26846928b6112eb0047140025dd9cc70 Mon Sep 17 00:00:00 2001 From: Obijuan Date: Tue, 26 Mar 2024 11:29:12 +0100 Subject: [PATCH] issue #361: Improve error message in windows when running apio drivers --ftdi-enable --- apio/managers/drivers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apio/managers/drivers.py b/apio/managers/drivers.py index 53507280..4cbc9e37 100644 --- a/apio/managers/drivers.py +++ b/apio/managers/drivers.py @@ -406,6 +406,9 @@ def _ftdi_enable_windows(self): zadig_ini_path = drivers_share_dir / "zadig.ini" zadig_ini = Path("zadig.ini") + # -- TODO: Refactor: too many opertions inside the try + # -- Divide it into smaller operations and document it + try: if util.check_package( self.name, self.version, self.spec_version, drivers_bin_dir @@ -425,8 +428,19 @@ def _ftdi_enable_windows(self): click.secho("FTDI drivers configuration finished", fg="green") else: result = 1 + + # -- TODO: Check what type of exception is raised in windows + # -- and change "Exception" by the specific exception type except Exception as exc: click.secho("Error: " + str(exc), fg="red") + click.secho( + "Trying to execute zadig.exe in command line, " + "but an error ocurred" + ) + click.secho( + "Please, execute the command again in the command line with" + " administrator privilegdes" + ) result = 1 finally: # Remove zadig.ini