Skip to content

Commit eb73d20

Browse files
committed
refactor(engines): route engine logs through output helpers
Signed-off-by: Samuel Amen Ague <ague.samuel27@gmail.com>
1 parent e570ab2 commit eb73d20

3 files changed

Lines changed: 12 additions & 31 deletions

File tree

pycompiler_ark/engines/cx_freeze/__init__.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
engine_register,
3535
translate,
3636
)
37-
from pycompiler_ark.engine_sdk.utils import log_with_level
37+
from pycompiler_ark.Ui import output
3838

3939

4040
@engine_register
@@ -154,12 +154,7 @@ def environment(self) -> Optional[dict[str, str]]:
154154
def on_success(self, gui, file: str) -> None:
155155
"""Handle successful compilation."""
156156
try:
157-
if hasattr(gui, "log"):
158-
log_with_level(
159-
gui,
160-
"success",
161-
"Compilation CX_Freeze terminée avec succès.",
162-
)
157+
output.success("Compilation CX_Freeze terminée avec succès.", gui=gui)
163158
except Exception:
164159
pass
165160

@@ -257,10 +252,7 @@ def create_tab(self, gui):
257252

258253
except Exception as e:
259254
try:
260-
if hasattr(gui, "log"):
261-
log_with_level(
262-
gui, "error", f"Erreur création onglet CX_Freeze: {e}"
263-
)
255+
output.error(f"Erreur création onglet CX_Freeze: {e}", gui=gui)
264256
except Exception:
265257
pass
266258
return None

pycompiler_ark/engines/nuitka/__init__.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
engine_register,
3434
translate,
3535
)
36-
from pycompiler_ark.engine_sdk.utils import log_with_level
36+
from pycompiler_ark.Ui import output
3737

3838

3939
@engine_register
@@ -174,12 +174,7 @@ def environment(self) -> Optional[dict[str, str]]:
174174
def on_success(self, gui, file: str) -> None:
175175
"""Handle successful compilation."""
176176
try:
177-
if hasattr(gui, "log"):
178-
log_with_level(
179-
gui,
180-
"success",
181-
"Compilation Nuitka terminée avec succès.",
182-
)
177+
output.success("Compilation Nuitka terminée avec succès.", gui=gui)
183178
except Exception:
184179
pass
185180

@@ -273,8 +268,7 @@ def create_tab(self, gui):
273268

274269
except Exception as e:
275270
try:
276-
if hasattr(gui, "log"):
277-
log_with_level(gui, "error", f"Erreur création onglet Nuitka: {e}")
271+
output.error(f"Erreur création onglet Nuitka: {e}", gui=gui)
278272
except Exception:
279273
pass
280274
return None

pycompiler_ark/engines/pyinstaller/__init__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
engine_register,
3535
translate,
3636
)
37-
from pycompiler_ark.engine_sdk.utils import log_with_level
37+
from pycompiler_ark.Ui import output
3838

3939

4040
@engine_register
@@ -155,12 +155,10 @@ def environment(self) -> Optional[dict[str, str]]:
155155
def on_success(self, gui, file: str) -> None:
156156
"""Handle successful compilation."""
157157
try:
158-
if hasattr(gui, "log"):
159-
log_with_level(
160-
gui,
161-
"success",
162-
"Compilation PyInstaller terminée avec succès.",
163-
)
158+
output.success(
159+
"Compilation PyInstaller terminée avec succès.",
160+
gui=gui,
161+
)
164162
except Exception:
165163
pass
166164

@@ -237,10 +235,7 @@ def create_tab(self, gui):
237235

238236
except Exception as e:
239237
try:
240-
if hasattr(gui, "log"):
241-
log_with_level(
242-
gui, "error", f"Erreur création onglet PyInstaller: {e}"
243-
)
238+
output.error(f"Erreur création onglet PyInstaller: {e}", gui=gui)
244239
except Exception:
245240
pass
246241
return None

0 commit comments

Comments
 (0)