diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b52cc2..e53b745b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta - fixed a minor UI glitch in the CNCJob UI - made sure that the `drillcncjob` and `cncjob` Tcl commands will use the `-las_power` parameter to set the laser power when using a preprocessor with `laser` in its name - now the `verbose log` parameter from the Preferences can take 3 values (0, 1, 2). Value = 0 means that the logging is disabled (mostly), value = 1 means that the logging is only in console and value = 3 means that the logging is now displayed in the Tcl box +- most of the logging (except in the Editors) is now done by the AppLogging class 30.01.2022 diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 943277af..9b340daa 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -1955,7 +1955,7 @@ class MainGUI(QtWidgets.QMainWindow): if flat_settings.contains("saved_gui_state"): saved_gui_state = flat_settings.value('saved_gui_state') self.restoreState(saved_gui_state) - log.debug("MainGUI.__init__() --> UI state restored from QSettings.") + self.app.log.debug("MainGUI.__init__() --> UI state restored from QSettings.") self.corner_snap_btn.setVisible(False) self.snap_magnet.setVisible(False) @@ -1966,7 +1966,7 @@ class MainGUI(QtWidgets.QMainWindow): self.geo_edit_toolbar.setDisabled(True) self.grb_edit_toolbar.setDisabled(True) - log.debug("MainGUI.__init__() --> UI layout restored from QSettings. Layout = %s" % str(layout)) + self.app.log.debug("MainGUI.__init__() --> UI layout restored from QSettings. Layout = %s" % str(layout)) else: self.exc_edit_toolbar.setDisabled(True) self.geo_edit_toolbar.setDisabled(True) @@ -1975,7 +1975,7 @@ class MainGUI(QtWidgets.QMainWindow): flat_settings.setValue('layout', "standard") # This will write the setting to the platform specific storage. del flat_settings - log.debug("MainGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'") + self.app.log.debug("MainGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'") # construct the Toolbar Lock menu entry to the context menu of the QMainWindow self.lock_action = QtGui.QAction() @@ -2177,7 +2177,7 @@ class MainGUI(QtWidgets.QMainWindow): self.app.defaults["global_def_win_h"]) self.splitter.setSizes([self.app.defaults["global_def_notebook_width"], 0]) except KeyError as e: - log.debug("appGUI.MainGUI.restore_main_win_geom() --> %s" % str(e)) + self.app.log.debug("appGUI.MainGUI.restore_main_win_geom() --> %s" % str(e)) def restore_toolbar_view(self): """ @@ -2327,7 +2327,7 @@ class MainGUI(QtWidgets.QMainWindow): """ Will clear the settings that are stored in QSettings. """ - log.debug("Clearing the settings in QSettings. GUI settings cleared.") + self.app.log.debug("Clearing the settings in QSettings. GUI settings cleared.") theme_settings = QtCore.QSettings("Open Source", "FlatCAM") theme_settings.setValue('theme', 'white') diff --git a/appGUI/PlotCanvas.py b/appGUI/PlotCanvas.py index 7ca6687a..d02c9b50 100644 --- a/appGUI/PlotCanvas.py +++ b/appGUI/PlotCanvas.py @@ -421,7 +421,7 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): else: dims = (self.pagesize_dict[workspace_size][0]/25.4, self.pagesize_dict[workspace_size][1]/25.4) except Exception as e: - log.error("PlotCanvas.draw_workspace() --> %s" % str(e)) + self.app.log.error("PlotCanvas.draw_workspace() --> %s" % str(e)) return if self.fcapp.defaults['global_workspace_orientation'] == 'l': diff --git a/appGUI/PlotCanvasLegacy.py b/appGUI/PlotCanvasLegacy.py index e3fa9dfe..42516a7c 100644 --- a/appGUI/PlotCanvasLegacy.py +++ b/appGUI/PlotCanvasLegacy.py @@ -17,7 +17,6 @@ from descartes.patch import PolygonPatch from shapely.geometry import Polygon, LineString, LinearRing from copy import deepcopy -import logging import numpy as np @@ -45,8 +44,6 @@ fcTranslate.apply_language('strings') if '_' not in builtins.__dict__: _ = gettext.gettext -log = logging.getLogger('base') - class CanvasCache(QtCore.QObject): """ @@ -96,7 +93,7 @@ class CanvasCache(QtCore.QObject): def run(self): - log.debug("CanvasCache Thread Started!") + self.app.self.app.log.debug("CanvasCache Thread Started!") self.plotcanvas.update_screen_request.connect(self.on_update_req) def on_update_req(self, extents): @@ -106,14 +103,14 @@ class CanvasCache(QtCore.QObject): :param extents: [xmin, xmax, ymin, ymax, zoom(optional)] """ - # log.debug("Canvas update requested: %s" % str(extents)) + # self.app.log.debug("Canvas update requested: %s" % str(extents)) # Note: This information below might be out of date. Establish # a protocol regarding when to change the canvas in the main # thread and when to check these values here in the background, # or pass this data in the signal (safer). - # log.debug("Size: %s [px]" % str(self.plotcanvas.get_axes_pixelsize())) - # log.debug("Density: %s [units/px]" % str(self.plotcanvas.get_density())) + # self.app.log.debug("Size: %s [px]" % str(self.plotcanvas.get_axes_pixelsize())) + # self.app.log.debug("Density: %s [units/px]" % str(self.plotcanvas.get_density())) # Move the requested screen portion to the main thread # and inform about the update: @@ -124,7 +121,7 @@ class CanvasCache(QtCore.QObject): # def on_app_obj.new_object_available(self): # - # log.debug("A new object is available. Should plot it!") + # self.app.log.debug("A new object is available. Should plot it!") class PlotCanvasLegacy(QtCore.QObject): @@ -366,7 +363,7 @@ class PlotCanvasLegacy(QtCore.QObject): return r_color, g_color, b_color def apply_axis_color(self): - self.app.log.debug('PlotCanvasLegacy.apply_axis_color() -> axis color applied') + self.app.self.app.log.debug('PlotCanvasLegacy.apply_axis_color() -> axis color applied') axis_default_color = self.app.defaults['global_axis_color'] @@ -558,7 +555,7 @@ class PlotCanvasLegacy(QtCore.QObject): else: dims = (self.pagesize_dict[workspace_size][0] / 25.4, self.pagesize_dict[workspace_size][1] / 25.4) except Exception as e: - log.error("PlotCanvasLegacy.draw_workspace() --> %s" % str(e)) + self.app.log.error("PlotCanvasLegacy.draw_workspace() --> %s" % str(e)) return if self.app.defaults['global_workspace_orientation'] == 'l': @@ -626,7 +623,7 @@ class PlotCanvasLegacy(QtCore.QObject): def on_new_screen(self): pass - # log.debug("Cache updated the screen!") + # self.app.log.debug("Cache updated the screen!") def new_cursor(self, axes=None, big=None): # if axes is None: @@ -691,7 +688,7 @@ class PlotCanvasLegacy(QtCore.QObject): # this happen at app initialization since self.app.geo_editor does not exist yet # I could reshuffle the object instantiating order but what's the point? # I could crash something else and that's pythonic, too - log.error("PlotCanvasLegacy.draw_cursor() big_cursor is False --> %s" % str(e)) + self.app.log.error("PlotCanvasLegacy.draw_cursor() big_cursor is False --> %s" % str(e)) else: try: self.ch_line.set_markeredgewidth(self.app.defaults["global_cursor_width"]) @@ -738,7 +735,7 @@ class PlotCanvasLegacy(QtCore.QObject): self.cv_line.remove() self.canvas.draw_idle() except Exception as e: - log.error("PlotCanvasLegacy.clear_cursor() big_cursor is True --> %s" % str(e)) + self.app.log.error("PlotCanvasLegacy.clear_cursor() big_cursor is True --> %s" % str(e)) self.canvas.restore_region(self.background) self.canvas.blit(self.axes.bbox) @@ -748,7 +745,7 @@ class PlotCanvasLegacy(QtCore.QObject): :param event: :return: """ - log.debug('on_key_down(): ' + str(event.key)) + self.app.log.debug('on_key_down(): ' + str(event.key)) self.key = event.key def on_key_up(self, event): @@ -783,7 +780,7 @@ class PlotCanvasLegacy(QtCore.QObject): try: self.figure.clf() except KeyError: - log.warning("KeyError in MPL figure.clf()") + self.app.log.warning("KeyError in MPL figure.clf()") # Re-build self.figure.add_axes(self.axes) @@ -821,7 +818,7 @@ class PlotCanvasLegacy(QtCore.QObject): :return: None """ - # FlatCAMApp.App.log.debug("PC.adjust_axes()") + # FlatCAMApp.App.self.app.log.debug("PC.adjust_axes()") if not self.app.collection.get_list() and not xmin and not ymin and not xmax and not ymax: xmin = -10 @@ -834,7 +831,7 @@ class PlotCanvasLegacy(QtCore.QObject): try: r = width / height except ZeroDivisionError: - log.error("Height is %f" % height) + self.app.log.error("Height is %f" % height) return canvas_w, canvas_h = self.canvas.get_width_height() canvas_r = float(canvas_w) / canvas_h @@ -1408,7 +1405,7 @@ class ShapeCollectionLegacy: try: self.app.plotcanvas.auto_adjust_axes() except Exception as e: - log.error("ShapeCollectionLegacy.clear() --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.clear() --> %s" % str(e)) if update is True: self.redraw() @@ -1447,7 +1444,7 @@ class ShapeCollectionLegacy: ) self.axes.add_patch(patch) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() excellon poly --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() excellon poly --> %s" % str(e)) else: try: if isinstance(local_shapes[element]['shape'], Polygon): @@ -1460,7 +1457,7 @@ class ShapeCollectionLegacy: x, y = local_shapes[element]['shape'].coords.xy self.axes.plot(x, y, 'r-', linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() excellon no poly --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() excellon no poly --> %s" % str(e)) elif obj_type == 'geometry': if type(local_shapes[element]['shape']) == Polygon: try: @@ -1474,7 +1471,7 @@ class ShapeCollectionLegacy: linestyle='-', linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() geometry poly --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() geometry poly --> %s" % str(e)) elif type(local_shapes[element]['shape']) == LineString or \ type(local_shapes[element]['shape']) == LinearRing: @@ -1484,7 +1481,7 @@ class ShapeCollectionLegacy: linestyle='-', linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() geometry no poly --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() geometry no poly --> %s" % str(e)) elif obj_type == 'gerber': if self.obj.options["multicolored"]: linespec = '-' @@ -1510,10 +1507,10 @@ class ShapeCollectionLegacy: linewidth=local_shapes[element]['linewidth']) self.axes.add_patch(patch) except AssertionError: - log.warning("A geometry component was not a polygon:") - log.warning(str(element)) + self.app.log.warning("A geometry component was not a polygon:") + self.app.log.warning(str(element)) except Exception as e: - log.error( + self.app.log.error( "PlotCanvasLegacy.ShepeCollectionLegacy.redraw() gerber 'solid' --> %s" % str(e)) else: try: @@ -1523,7 +1520,7 @@ class ShapeCollectionLegacy: x, y = ints.coords.xy self.axes.plot(x, y, linespec, linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() gerber no 'solid' --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() gerber no 'solid' --> %s" % str(e)) elif obj_type == 'cncjob': if local_shapes[element]['face_color'] is None: @@ -1536,7 +1533,7 @@ class ShapeCollectionLegacy: self.axes.plot(x, y, linespec, color=linecolor, linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() cncjob with face_color --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() cncjob with face_color --> %s" % str(e)) else: try: path_num += 1 @@ -1559,7 +1556,7 @@ class ShapeCollectionLegacy: linewidth=local_shapes[element]['linewidth']) self.axes.add_patch(patch) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() cncjob no face_color --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() cncjob no face_color --> %s" % str(e)) elif obj_type == 'utility': # not a FlatCAM object, must be utility if local_shapes[element]['face_color']: @@ -1573,7 +1570,7 @@ class ShapeCollectionLegacy: self.axes.add_patch(patch) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() utility poly with face_color --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() utility poly with face_color --> %s" % str(e)) else: if isinstance(local_shapes[element]['shape'], Polygon): try: @@ -1588,7 +1585,7 @@ class ShapeCollectionLegacy: self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-', linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() utility poly no face_color --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() utility poly no face_color --> %s" % str(e)) else: try: if local_shapes[element]['shape'] is not None: @@ -1596,7 +1593,7 @@ class ShapeCollectionLegacy: self.axes.plot(x, y, local_shapes[element]['color'], linestyle='-', linewidth=local_shapes[element]['linewidth']) except Exception as e: - log.error("ShapeCollectionLegacy.redraw() utility lines no face_color --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.redraw() utility lines no face_color --> %s" % str(e)) self.app.plotcanvas.auto_adjust_axes() def set(self, text, pos, visible=True, font_size=16, color=None): @@ -1626,7 +1623,7 @@ class ShapeCollectionLegacy: try: self.axes.annotate(text[idx], xy=pos[idx], xycoords='data', fontsize=font_size, color=color) except Exception as e: - log.error("ShapeCollectionLegacy.set() --> %s" % str(e)) + self.app.log.error("ShapeCollectionLegacy.set() --> %s" % str(e)) self.app.plotcanvas.auto_adjust_axes() diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 2b3e355b..a4ccd931 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -408,7 +408,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): def set_ui(self, ui): FlatCAMObj.set_ui(self, ui) - log.debug("FlatCAMCNCJob.set_ui()") + self.app.log.debug("FlatCAMCNCJob.set_ui()") assert isinstance(self.ui, CNCObjectUI), \ "Expected a CNCObjectUI, got %s" % type(self.ui) @@ -1403,7 +1403,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): :return: """ - log.debug("FlatCAMObj.FlatCAMECNCjob.convert_units()") + self.app.log.debug("FlatCAMObj.FlatCAMECNCjob.convert_units()") factor = CNCjob.convert_units(self, units) self.options["tooldia"] = float(self.options["tooldia"]) * factor diff --git a/appObjects/FlatCAMDocument.py b/appObjects/FlatCAMDocument.py index 7e438bdb..e8c5b754 100644 --- a/appObjects/FlatCAMDocument.py +++ b/appObjects/FlatCAMDocument.py @@ -9,8 +9,6 @@ # ########################################################## # File modified by: Marius Stanciu # # ########################################################## -from PyQt6 import QtGui - from appEditors.AppTextEditor import AppTextEditor from appObjects.FlatCAMObj import * @@ -33,7 +31,7 @@ class DocumentObject(FlatCAMObj): def __init__(self, name): self.decimals = self.app.decimals - log.debug("Creating a Document object...") + self.app.log.debug("Creating a Document object...") FlatCAMObj.__init__(self, name) self.kind = "document" @@ -55,7 +53,7 @@ class DocumentObject(FlatCAMObj): def set_ui(self, ui): FlatCAMObj.set_ui(self, ui) - log.debug("DocumentObject.set_ui()") + self.app.log.debug("DocumentObject.set_ui()") assert isinstance(self.ui, DocumentObjectUI), \ "Expected a DocumentObjectUI, got %s" % type(self.ui) diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 622b8c17..2a88ec7a 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -1554,8 +1554,7 @@ class GeometryObject(FlatCAMObj, Geometry): self.read_form_item('multicolored') self.plot() - @staticmethod - def merge(geo_list, geo_final, multi_geo=None, fuse_tools=None): + def merge(self, geo_list, geo_final, multi_geo=None, fuse_tools=None): """ Merges the geometry of objects in grb_list into the geometry of geo_final. @@ -1580,7 +1579,7 @@ class GeometryObject(FlatCAMObj, Geometry): try: new_options[option] = deepcopy(geo_obj.options[option]) except Exception as e: - log.error("Failed to copy option %s. Error: %s" % (str(option), str(e))) + self.app.log.error("Failed to copy option %s. Error: %s" % (str(option), str(e))) # Expand lists if type(geo_obj) is list: @@ -1596,7 +1595,7 @@ class GeometryObject(FlatCAMObj, Geometry): new_solid_geometry += deepcopy(geo_obj.solid_geometry.geoms) except Exception as e: new_solid_geometry.append(geo_obj.solid_geometry) - log.error("GeometryObject.merge() --> %s" % str(e)) + self.app.log.error("GeometryObject.merge() --> %s" % str(e)) # find the tool_uid maximum value in the geo_final try: diff --git a/appObjects/FlatCAMScript.py b/appObjects/FlatCAMScript.py index 5923ca85..2ab85a1c 100644 --- a/appObjects/FlatCAMScript.py +++ b/appObjects/FlatCAMScript.py @@ -33,7 +33,7 @@ class ScriptObject(FlatCAMObj): def __init__(self, name): self.decimals = self.app.decimals - log.debug("Creating a ScriptObject object...") + self.app.log.debug("Creating a ScriptObject object...") FlatCAMObj.__init__(self, name) self.kind = "script" @@ -62,7 +62,7 @@ class ScriptObject(FlatCAMObj): :return: """ FlatCAMObj.set_ui(self, ui) - log.debug("ScriptObject.set_ui()") + self.app.log.debug("ScriptObject.set_ui()") assert isinstance(self.ui, ScriptObjectUI), \ "Expected a ScriptObjectUI, got %s" % type(self.ui) @@ -135,7 +135,7 @@ class ScriptObject(FlatCAMObj): # self.script_editor_tab.code_editor.setPlainText(self.source_file) self.script_editor_tab.load_text(self.source_file, move_to_end=True) except Exception as e: - log.error("ScriptObject.set_ui() --> %s" % str(e)) + self.app.log.error("ScriptObject.set_ui() --> %s" % str(e)) self.script_editor_tab.t_frame.show() diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index 3e11b15a..c62787f1 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -1486,7 +1486,7 @@ class Gerber(Geometry): # Flash should not happen here if current_operation_code == 3: - log.error("Trying to flash within arc. (%d)" % line_num) + self.app.log.error("Trying to flash within arc. (%d)" % line_num) continue if quadrant_mode == 'MULTI': @@ -1531,7 +1531,7 @@ class Gerber(Geometry): ] valid = False - log.debug("I: %f J: %f" % (i, j)) + # self.app.log.debug("I: %f J: %f" % (i, j)) for center in center_candidates: radius = np.sqrt(i ** 2 + j ** 2) @@ -1547,14 +1547,14 @@ class Gerber(Geometry): start = np.arctan2(-j, -i) # Start angle stop = np.arctan2(-center[1] + circular_y, -center[0] + circular_x) # Stop angle angle = abs(arc_angle(start, stop, arcdir[current_interpolation_mode])) - log.debug("ARC START: %f, %f CENTER: %f, %f STOP: %f, %f" % - (current_x, current_y, center[0], center[1], circular_x, circular_y)) - log.debug("START Ang: %f, STOP Ang: %f, DIR: %s, ABS: %.12f <= %.12f: %s" % - (start * 180 / np.pi, stop * 180 / np.pi, arcdir[current_interpolation_mode], - angle * 180 / np.pi, np.pi / 2 * 180 / np.pi, angle <= (np.pi + 1e-6) / 2)) + # self.app.log.debug("ARC START: %f, %f CENTER: %f, %f STOP: %f, %f" % + # (current_x, current_y, center[0], center[1], circular_x, circular_y)) + # self.app.log.debug("START Ang: %f, STOP Ang: %f, DIR: %s, ABS: %.12f <= %.12f: %s" % + # (start * 180 / np.pi, stop * 180 / np.pi, arcdir[current_interpolation_mode], + # angle * 180 / np.pi, np.pi / 2 * 180 / np.pi, angle <= (np.pi + 1e-6) / 2)) if angle <= (np.pi + 1e-6) / 2: - log.debug("########## ACCEPTING ARC ############") + # self.app.log.debug("########## ACCEPTING ARC ############") this_arc = arc(center, radius, start, stop, arcdir[current_interpolation_mode], self.steps_per_circle) @@ -1744,8 +1744,7 @@ class Gerber(Geometry): if is_excellon_gx2 is True: return 'drill' - @staticmethod - def create_flash_geometry(location, aperture, steps_per_circle=None): + def create_flash_geometry(self, location, aperture, steps_per_circle=None): # self.app.log.debug('Flashing @%s, Aperture: %s' % (location, aperture)) @@ -1799,10 +1798,10 @@ class Gerber(Geometry): loc = location.coords[0] flash_geo = aperture['macro'].make_geometry(aperture['modifiers']) if flash_geo.is_empty: - log.warning("Empty geometry for Aperture Macro: %s" % str(aperture['macro'].name)) + self.app.log.warning("Empty geometry for Aperture Macro: %s" % str(aperture['macro'].name)) return affinity.translate(flash_geo, xoff=loc[0], yoff=loc[1]) - log.warning("Unknown aperture type: %s" % aperture['type']) + self.app.log.warning("Unknown aperture type: %s" % aperture['type']) return None def create_geometry(self): diff --git a/appParsers/ParseHPGL2.py b/appParsers/ParseHPGL2.py index 6692e067..844d3a0a 100644 --- a/appParsers/ParseHPGL2.py +++ b/appParsers/ParseHPGL2.py @@ -217,7 +217,7 @@ class HPGL2: # ################### match = self.comment_re.search(gline) if match: - log.debug(str(match.group(1))) + self.app.log.debug(str(match.group(1))) continue # search for the initialization @@ -410,13 +410,13 @@ class HPGL2: continue # ## Line did not match any pattern. Warn user. - log.warning("Line ignored (%d): %s" % (line_num, gline)) + self.app.log.warning("Line ignored (%d): %s" % (line_num, gline)) if not geo_buffer and not self.solid_geometry: - log.error("Object is not HPGL2 file or empty. Aborting Object creation.") + self.app.log.error("Object is not HPGL2 file or empty. Aborting Object creation.") return 'fail' - log.warning("Joining %d polygons." % len(geo_buffer)) + self.app.log.warning("Joining %d polygons." % len(geo_buffer)) self.app.inform.emit('%s: %d.' % (_("Gerber processing. Joining polygons"), len(geo_buffer))) new_poly = unary_union(geo_buffer) @@ -427,7 +427,7 @@ class HPGL2: traceback.print_tb(tb) print(traceback.format_exc()) - log.error("HPGL2 PARSING FAILED. Line %d: %s" % (line_num, gline)) + self.app.log.error("HPGL2 PARSING FAILED. Line %d: %s" % (line_num, gline)) loc = '%s #%d %s: %s\n' % (_("HPGL2 Line"), line_num, _("HPGL2 Line Content"), gline) + repr(err) self.app.inform.emit('[ERROR] %s\n%s:' % (_("HPGL2 Parser ERROR"), loc)) diff --git a/appPlugins/ToolCalibration.py b/appPlugins/ToolCalibration.py index 4e4d2e5e..20fd1ecb 100644 --- a/appPlugins/ToolCalibration.py +++ b/appPlugins/ToolCalibration.py @@ -351,7 +351,7 @@ class ToolCalibration(AppTool): self.ui.top_left_coordy_found.set_value('') def gcode_header(self): - log.debug("ToolCalibration.gcode_header()") + self.app.log.debug("ToolCalibration.gcode_header()") time_str = "{:%A, %d %B %Y at %H:%M}".format(datetime.now()) gcode = '(G-CODE GENERATED BY FLATCAM v%s - www.flatcam.org - Version Date: %s)\n' % \ @@ -634,7 +634,7 @@ class ToolCalibration(AppTool): try: self.cal_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolCalibration.on_cal_button_click() --> %s" % str(e)) + self.app.log.error("ToolCalibration.on_cal_button_click() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) return @@ -648,7 +648,7 @@ class ToolCalibration(AppTool): origin_x = self.click_points[0][0] origin_y = self.click_points[0][1] except IndexError as e: - log.debug("ToolCalibration.new_calibrated_object() --> %s" % str(e)) + self.app.log.debug("ToolCalibration.new_calibrated_object() --> %s" % str(e)) return 'fail' scalex = self.ui.scalex_entry.get_value() @@ -700,7 +700,7 @@ class ToolCalibration(AppTool): if obj.tools: obj_init.tools = deepcopy(obj.tools) except Exception as err: - log.error("ToolCalibration.new_calibrated_object.initialize_gerber() --> %s" % str(err)) + self.app.log.error("ToolCalibration.new_calibrated_object.initialize_gerber() --> %s" % str(err)) obj_init.scale(xfactor=scalex, yfactor=scaley, point=(origin_x, origin_y)) obj_init.skew(angle_x=skewx, angle_y=skewy, point=(origin_x, origin_y)) @@ -727,7 +727,7 @@ class ToolCalibration(AppTool): if obj is None: self.app.inform.emit('[WARNING_NOTCL] %s' % _("No object is selected.")) - log.debug("ToolCalibration.new_calibrated_object() --> No object to calibrate") + self.app.log.debug("ToolCalibration.new_calibrated_object() --> No object to calibrate") return 'fail' try: @@ -738,7 +738,7 @@ class ToolCalibration(AppTool): elif obj.kind.lower() == 'geometry': self.app.app_obj.new_object("geometry", str(obj_name), initialize_geometry) except Exception as e: - log.error("ToolCalibration.new_calibrated_object() --> %s" % str(e)) + self.app.log.error("ToolCalibration.new_calibrated_object() --> %s" % str(e)) return "Operation failed: %s" % str(e) def disconnect_cal_events(self): diff --git a/appPlugins/ToolCopperThieving.py b/appPlugins/ToolCopperThieving.py index d0219e07..a6b046ad 100644 --- a/appPlugins/ToolCopperThieving.py +++ b/appPlugins/ToolCopperThieving.py @@ -273,7 +273,7 @@ class ToolCopperThieving(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolCopperThieving.on_add_robber_bar_click() --> %s" % str(e)) + self.app.log.error("ToolCopperThieving.on_add_robber_bar_click() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return @@ -371,7 +371,7 @@ class ToolCopperThieving(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolCopperThieving.on_add_copper_thieving_click() --> %s" % str(e)) + self.app.log.error("ToolCopperThieving.on_add_copper_thieving_click() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return @@ -556,7 +556,7 @@ class ToolCopperThieving(AppTool): # ####### Read the parameters ######################################### # ##################################################################### - log.debug("Copper Thieving Tool started. Reading parameters.") + self.app.log.debug("Copper Thieving Tool started. Reading parameters.") self.app.inform.emit(_("Copper Thieving Tool started. Reading parameters.")) ref_selected = self.ui.reference_combo.get_value() @@ -582,7 +582,7 @@ class ToolCopperThieving(AppTool): # ######################################################################################################### # Prepare isolation polygon. This will create the clearance over the Gerber features # ######################################################################################################### - log.debug("Copper Thieving Tool. Preparing isolation polygons.") + self.app.log.debug("Copper Thieving Tool. Preparing isolation polygons.") tool_obj.app.inform.emit(_("Copper Thieving Tool. Preparing isolation polygons.")) # variables to display the percentage of work done @@ -628,7 +628,7 @@ class ToolCopperThieving(AppTool): # ######################################################################################################### # Prepare the area to fill with copper. # ######################################################################################################### - log.debug("Copper Thieving Tool. Preparing areas to fill with copper.") + tool_obj.app.log.debug("Copper Thieving Tool. Preparing areas to fill with copper.") tool_obj.app.inform.emit(_("Copper Thieving Tool. Preparing areas to fill with copper.")) try: @@ -637,7 +637,7 @@ class ToolCopperThieving(AppTool): else: working_obj = ref_obj except Exception as e: - log.error("ToolCopperThieving.copper_thieving() --> %s" % str(e)) + tool_obj.app.log.error("ToolCopperThieving.copper_thieving() --> %s" % str(e)) return 'fail' tool_obj.app.proc_container.update_view_text(' %s' % _("Working...")) @@ -678,7 +678,7 @@ class ToolCopperThieving(AppTool): return 'fail' except Exception as e: - log.error("ToolCopperFIll.copper_thieving() 'itself' --> %s" % str(e)) + tool_obj.app.log.error("ToolCopperFIll.copper_thieving() 'itself' --> %s" % str(e)) tool_obj.app.inform.emit('[ERROR_NOTCL] %s' % _("No object available.")) return 'fail' elif ref_selected == 1: # 'area' @@ -985,7 +985,7 @@ class ToolCopperThieving(AppTool): try: self.sm_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolCopperThieving.on_add_ppm_click() --> %s" % str(e)) + self.app.log.error("ToolCopperThieving.on_add_ppm_click() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return diff --git a/appPlugins/ToolCutOut.py b/appPlugins/ToolCutOut.py index a3763097..b6feadcc 100644 --- a/appPlugins/ToolCutOut.py +++ b/appPlugins/ToolCutOut.py @@ -1025,7 +1025,7 @@ class CutOut(AppTool): # self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab) app_obj.should_we_save = True except Exception as ee: - log.error(str(ee)) + app_obj.app.log.error(str(ee)) self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) @@ -1037,7 +1037,7 @@ class CutOut(AppTool): try: cutout_obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("CutOut.on_rectangular_cutout() --> %s" % str(e)) + self.app.log.error("CutOut.on_rectangular_cutout() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), name)) return "Could not retrieve object: %s" % name @@ -1333,7 +1333,7 @@ class CutOut(AppTool): # self_c.app.ui.notebook.setCurrentWidget(self_c.app.ui.project_tab) app_obj.should_we_save = True except Exception as ee: - log.error(str(ee)) + app_obj.log.error(str(ee)) self.app.worker_task.emit( { @@ -1425,7 +1425,7 @@ class CutOut(AppTool): try: obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("CutOut.on_freeform_cutout() --> %s" % str(e)) + self.app.log.error("CutOut.on_freeform_cutout() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), name)) return "Could not retrieve object: %s" % name @@ -1504,7 +1504,7 @@ class CutOut(AppTool): try: ret = self.app.app_obj.new_object("excellon", outname, obj_init, autoselected=False) except Exception as e: - log.error("Error on Drill Cutting Excellon object creation: %s" % str(e)) + self.app.log.error("Error on Drill Cutting Excellon object creation: %s" % str(e)) return if ret != 'fail': @@ -1517,7 +1517,7 @@ class CutOut(AppTool): try: self.man_cutout_obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("CutOut.on_manual_cutout() --> %s" % str(e)) + self.app.log.error("CutOut.on_manual_cutout() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), name)) return @@ -1561,7 +1561,7 @@ class CutOut(AppTool): try: self.man_cutout_obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("CutOut.on_manual_cutout() --> %s" % str(e)) + self.app.log.error("CutOut.on_manual_cutout() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), name)) return @@ -1664,7 +1664,7 @@ class CutOut(AppTool): try: cutout_obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("CutOut.on_manual_geo() --> %s" % str(e)) + self.app.log.error("CutOut.on_manual_geo() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), name)) return "Could not retrieve object: %s" % name @@ -2073,8 +2073,7 @@ class CutOut(AppTool): geo = self.cutting_geo(pos=(l_x, l_y)) self.draw_utility_geometry(geo=geo) - @staticmethod - def subtract_poly_from_geo(solid_geo, pts): + def subtract_poly_from_geo(self, solid_geo, pts): """ Subtract polygon made from points from the given object. This only operates on the paths in the original geometry, @@ -2102,7 +2101,7 @@ class CutOut(AppTool): # pathonly should be always True, otherwise polygons are not subtracted flat_geometry = CutOut.flatten(geometry=solid_geo) - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) polygon = Polygon(points) toolgeo = unary_union(polygon) @@ -2111,7 +2110,7 @@ class CutOut(AppTool): if type(target) == LineString or type(target) == LinearRing: diffs.append(target.difference(toolgeo)) else: - log.warning("Not implemented.") + self.app.log.warning("Not implemented.") return unary_union(diffs) @@ -2188,7 +2187,7 @@ class CutOut(AppTool): # flatten() takes care of possible empty geometry making sure that is filtered flat_geometry = CutOut.flatten(target_geo) - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) toolgeo = unary_union(subtractor) diff --git a/appPlugins/ToolDistance.py b/appPlugins/ToolDistance.py index a35fd24b..19c9338f 100644 --- a/appPlugins/ToolDistance.py +++ b/appPlugins/ToolDistance.py @@ -549,7 +549,7 @@ class Distance(AppTool): self.app.ui.update_location_labels(dx=dx, dy=dy, x=pos[0], y=pos[1]) except Exception as e: - log.error("Distance.on_mouse_move() position --> %s" % str(e)) + self.app.log.error("Distance.on_mouse_move() position --> %s" % str(e)) self.app.ui.position_label.setText("") self.app.ui.rel_position_label.setText("") return diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index bcc061eb..9b8e91f1 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -669,7 +669,7 @@ class ToolDrilling(AppTool, Excellon): QtCore.QTimer.singleShot(20, self.build_tool_ui) def build_tool_ui(self): - log.debug("ToolDrilling.build_tool_ui()") + self.app.log.debug("ToolDrilling.build_tool_ui()") self.ui_disconnect() # order the tools by tool diameter if it's the case @@ -927,7 +927,7 @@ class ToolDrilling(AppTool, Excellon): ) def on_object_changed(self): - log.debug("ToolDrilling.on_object_changed()") + self.app.log.debug("ToolDrilling.on_object_changed()") # updated units self.units = self.app.app_units.upper() @@ -1173,7 +1173,7 @@ class ToolDrilling(AppTool, Excellon): self.replace_tools() def replace_tools(self): - log.debug("ToolDrilling.replace_tools()") + self.app.log.debug("ToolDrilling.replace_tools()") if self.excellon_obj: new_tools_dict = deepcopy(self.excellon_tools) @@ -1318,7 +1318,7 @@ class ToolDrilling(AppTool, Excellon): self.ui_connect() return except Exception as e: - log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) + self.app.log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) self.blockSignals(False) self.ui_connect() return @@ -1345,7 +1345,7 @@ class ToolDrilling(AppTool, Excellon): try: self.tool_form_fields[form_key].set_value(dict_storage[form_key]) except Exception as e: - log.error("ToolDrilling.storage_to_form() tool parameters --> %s" % str(e)) + self.app.log.error("ToolDrilling.storage_to_form() tool parameters --> %s" % str(e)) pass # update the Common parameters @@ -1355,7 +1355,7 @@ class ToolDrilling(AppTool, Excellon): try: self.general_form_fields[form_key].set_value(dict_storage[form_key]) except Exception as e: - log.error("ToolDrilling.storage_to_form() -> common parameters --> %s" % str(e)) + self.app.log.error("ToolDrilling.storage_to_form() -> common parameters --> %s" % str(e)) pass def form_to_storage(self): @@ -1444,7 +1444,7 @@ class ToolDrilling(AppTool, Excellon): def on_apply_param_to_all_clicked(self): if self.ui.tools_table.rowCount() == 0: # there is no tool in tool table so we can't save the GUI elements values to storage - log.debug("ToolDrilling.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") + self.app.log.debug("ToolDrilling.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") return self.blockSignals(True) @@ -1872,7 +1872,7 @@ class ToolDrilling(AppTool, Excellon): except KeyError: points[tool_key] = [drill_pt] - log.debug("Found %d TOOLS with drills." % len(points)) + self.app.log.debug("Found %d TOOLS with drills." % len(points)) # ############################################################################################################# # ############ SLOTS TO DRILLS CONVERSION SECTION ############################################################# @@ -1903,7 +1903,7 @@ class ToolDrilling(AppTool, Excellon): points[tool_key] += new_drills except Exception: points[tool_key] = new_drills - log.debug("Found %d TOOLS with drills after converting slots to drills." % len(points)) + self.app.log.debug("Found %d TOOLS with drills after converting slots to drills." % len(points)) return points @@ -2288,18 +2288,18 @@ class ToolDrilling(AppTool, Excellon): job_obj.create_geometry() if used_exc_optim_type == 'M': - log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % - str(job_obj.measured_distance)) + app_obj.log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % + str(job_obj.measured_distance)) elif used_exc_optim_type == 'B': - log.debug("The total travel distance with OR-TOOLS Basic Algorithm is: %s" % - str(job_obj.measured_distance)) + app_obj.log.debug("The total travel distance with OR-TOOLS Basic Algorithm is: %s" % + str(job_obj.measured_distance)) elif used_exc_optim_type == 'T': - log.debug( + app_obj.log.debug( "The total travel distance with Travelling Salesman Algorithm is: %s" % str(job_obj.measured_distance)) else: - log.debug("The total travel distance with with no optimization is: %s" % - str(job_obj.measured_distance)) + app_obj.log.debug("The total travel distance with with no optimization is: %s" % + str(job_obj.measured_distance)) # ######################################################################################################### # ############################# Calculate DISTANCE and ESTIMATED TIME ##################################### @@ -2310,8 +2310,8 @@ class ToolDrilling(AppTool, Excellon): job_obj.measured_distance += abs(distance_euclidian( job_obj.oldx, job_obj.oldy, job_obj.xy_end[0], job_obj.xy_end[1]) ) - log.debug("The total travel distance including travel to end position is: %s" % - str(job_obj.measured_distance) + '\n') + app_obj.log.debug("The total travel distance including travel to end position is: %s" % + str(job_obj.measured_distance) + '\n') job_obj.travel_distance = job_obj.measured_distance # I use the value of self.feedrate_rapid for the feadrate in case of the measure_lift_distance and for diff --git a/appPlugins/ToolEtchCompensation.py b/appPlugins/ToolEtchCompensation.py index 83138283..2715133a 100644 --- a/appPlugins/ToolEtchCompensation.py +++ b/appPlugins/ToolEtchCompensation.py @@ -49,7 +49,7 @@ class ToolEtchCompensation(AppTool): def run(self, toggle=True): self.app.defaults.report_usage("ToolEtchCompensation()") - log.debug("ToolEtchCompensation() is running ...") + self.app.log.debug("ToolEtchCompensation() is running ...") if toggle: # if the splitter is hidden, display it @@ -178,7 +178,7 @@ class ToolEtchCompensation(AppTool): self.ui.mils_to_um_entry.set_value(val, self.decimals) def on_compensate(self): - log.debug("ToolEtchCompensation.on_compensate()") + self.app.log.debug("ToolEtchCompensation.on_compensate()") ratio_type = self.ui.ratio_radio.get_value() thickness = self.ui.thick_entry.get_value() / 1000 # in microns diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index 03ca2fb7..daebc9a2 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -785,7 +785,7 @@ class ToolExtract(AppTool): try: self.app.app_obj.new_object("gerber", outname, obj_init, autoselected=False) except Exception as e: - log.error("Error on Extracted Soldermask Gerber object creation: %s" % str(e)) + self.app.log.error("Error on Extracted Soldermask Gerber object creation: %s" % str(e)) return def on_extract_cutout_click(self): @@ -860,7 +860,7 @@ class ToolExtract(AppTool): try: self.app.app_obj.new_object("gerber", outname, obj_init) except Exception as e: - log.error("Error on Extracted Cutout Gerber object creation: %s" % str(e)) + self.app.log.error("Error on Extracted Cutout Gerber object creation: %s" % str(e)) return def on_extract_drills_method_changed(self, val): diff --git a/appPlugins/ToolFiducials.py b/appPlugins/ToolFiducials.py index de9bfc0e..881e5854 100644 --- a/appPlugins/ToolFiducials.py +++ b/appPlugins/ToolFiducials.py @@ -288,7 +288,7 @@ class ToolFiducials(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolFiducials.execute() --> %s" % str(e)) + self.app.log.error("ToolFiducials.execute() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) self.app.ui.notebook.setDisabled(False) self.app.call_source = "app" @@ -590,7 +590,7 @@ class ToolFiducials(AppTool): try: self.sm_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolFiducials.add_soldermask_opening() --> %s" % str(e)) + self.app.log.error("ToolFiducials.add_soldermask_opening() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return @@ -711,7 +711,7 @@ class ToolFiducials(AppTool): copper_obj.options['xmax'] = c copper_obj.options['ymax'] = d except Exception as e: - log.error("ToolFiducials.on_exit() copper_obj bounds error --> %s" % str(e)) + self.app.log.error("ToolFiducials.on_exit() copper_obj bounds error --> %s" % str(e)) for ob_name in self.sm_obj_set: try: diff --git a/appPlugins/ToolFilm.py b/appPlugins/ToolFilm.py index e9e89883..4fc5dfa1 100644 --- a/appPlugins/ToolFilm.py +++ b/appPlugins/ToolFilm.py @@ -307,7 +307,7 @@ class Film(AppTool): self.ui.film_scale_stroke_entry.set_value(float(scale_stroke_width)) def on_film_creation(self): - log.debug("ToolFilm.Film.on_film_creation() started ...") + self.app.log.debug("ToolFilm.Film.on_film_creation() started ...") try: name = self.ui.tf_object_combo.currentText() @@ -347,7 +347,7 @@ class Film(AppTool): self.generate_negative_film(name, boxname, factor=scale_stroke_width, ftype=file_type) def generate_positive_normal_film(self, name, boxname, factor, ftype='svg'): - log.debug("ToolFilm.Film.generate_positive_normal_film() started ...") + self.app.log.debug("ToolFilm.Film.generate_positive_normal_film() started ...") scale_factor_x = 1 scale_factor_y = 1 @@ -418,7 +418,7 @@ class Film(AppTool): film_obj = self.app.collection.get_by_name(name) if source == 'exc': - log.debug("ToolFilm.Film.generate_positive_punched_film() with Excellon source started ...") + self.app.log.debug("ToolFilm.Film.generate_positive_punched_film() with Excellon source started ...") try: exc_name = self.ui.exc_combo.currentText() @@ -439,7 +439,7 @@ class Film(AppTool): self.generate_positive_normal_film(outname, boxname, factor=factor, ftype=ftype) else: - log.debug("ToolFilm.Film.generate_positive_punched_film() with Pad center source started ...") + self.app.log.debug("ToolFilm.Film.generate_positive_punched_film() with Pad center source started ...") punch_size = float(self.ui.punch_size_spinner.get_value()) @@ -491,7 +491,7 @@ class Film(AppTool): self.generate_positive_normal_film(outname, boxname, factor=factor, ftype=ftype) def generate_negative_film(self, name, boxname, factor, ftype='svg'): - log.debug("ToolFilm.Film.generate_negative_film() started ...") + self.app.log.debug("ToolFilm.Film.generate_negative_film() started ...") use_convex_hull = self.ui.convex_box_cb.get_value() rounded_box = self.ui.rounded_cb.get_value() @@ -643,7 +643,7 @@ class Film(AppTool): transparency_level = opacity_val def make_negative_film(color, transparency_level, scale_factor_x, scale_factor_y, use_convex_hull, rounded_box): - log.debug("FilmTool.export_negative().make_negative_film()") + self.app.log.debug("FilmTool.export_negative().make_negative_film()") self.screen_dpi = self.app.qapp.screens()[0].logicalDotsPerInch() @@ -909,7 +909,7 @@ class Film(AppTool): scale_factor_x=scale_factor_x, scale_factor_y=scale_factor_y, use_convex_hull=use_convex_hull, rounded_box=rounded_box) except Exception as e: - log.error("export_negative() process -> %s" % str(e)) + self.app.log.error("export_negative() process -> %s" % str(e)) return self.app.worker_task.emit({'fcn': job_thread_film, 'params': []}) @@ -976,7 +976,7 @@ class Film(AppTool): transparency_level = opacity_val def make_positive_film(color, transparency_level, scale_factor_x, scale_factor_y): - log.debug("FilmTool.export_positive().make_positive_film()") + self.app.log.debug("FilmTool.export_positive().make_positive_film()") self.screen_dpi = self.app.qapp.screens()[0].logicalDotsPerInch() diff --git a/appPlugins/ToolFollow.py b/appPlugins/ToolFollow.py index 4791b1a0..683f2f56 100644 --- a/appPlugins/ToolFollow.py +++ b/appPlugins/ToolFollow.py @@ -295,7 +295,7 @@ class ToolFollow(AppTool, Gerber): float(eval(dia)) for dia in temp_tools if dia != '' ] except Exception as e: - log.error("ToolFollow.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) + self.app.log.error("ToolFollow.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) return 'fail' # store here the default data for Geometry Data @@ -360,7 +360,7 @@ class ToolFollow(AppTool, Gerber): float(eval(dia)) for dia in temp_tools if dia != '' ] except Exception as e: - log.error("ToolFollow.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) + app_obj.log.error("ToolFollow.follow_geo -> At least one tool diameter needed. -> %s" % str(e)) return 'fail' # store here the default data for Geometry Data @@ -642,7 +642,7 @@ class ToolFollow(AppTool, Gerber): self.app.plotcanvas.graph_event_disconnect(self.mm) self.app.plotcanvas.graph_event_disconnect(self.kp) except Exception as e: - log.error("ToolFollow.on_key_press() _1 --> %s" % str(e)) + self.app.log.error("ToolFollow.on_key_press() _1 --> %s" % str(e)) self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot) diff --git a/appPlugins/ToolInvertGerber.py b/appPlugins/ToolInvertGerber.py index aaaff114..d04a158b 100644 --- a/appPlugins/ToolInvertGerber.py +++ b/appPlugins/ToolInvertGerber.py @@ -48,7 +48,7 @@ class ToolInvertGerber(AppTool): def run(self, toggle=True): self.app.defaults.report_usage("ToolInvertGerber()") - log.debug("ToolInvertGerber() is running ...") + self.app.log.debug("ToolInvertGerber() is running ...") if toggle: # if the splitter is hidden, display it diff --git a/appPlugins/ToolIsolation.py b/appPlugins/ToolIsolation.py index ba2d9fb5..f7241c07 100644 --- a/appPlugins/ToolIsolation.py +++ b/appPlugins/ToolIsolation.py @@ -421,7 +421,8 @@ class ToolIsolation(AppTool, Gerber): dias = self.app.defaults["tools_iso_tooldia"] if not dias: - log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> Plugins -> Isolation Tools.") + self.app.log.error( + "At least one tool diameter needed. Verify in Edit -> Preferences -> Plugins -> Isolation Tools.") return self.tooluid = 0 @@ -906,7 +907,7 @@ class ToolIsolation(AppTool, Gerber): self.ui_connect() return except Exception as e: - log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) + self.app.log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) self.ui_connect() return @@ -924,7 +925,7 @@ class ToolIsolation(AppTool, Gerber): if key == 'data': self.storage_to_form(tooluid_value['data']) except Exception as e: - log.error("ToolIsolation ---> update_ui() " + str(e)) + self.app.log.error("ToolIsolation ---> update_ui() " + str(e)) else: self.ui.tool_data_label.setText( "%s: %s" % (_('Parameters for'), _("Multiple Tools")) @@ -939,7 +940,7 @@ class ToolIsolation(AppTool, Gerber): try: self.form_fields[form_key].set_value(dict_storage[form_key]) except Exception as e: - log.error("ToolIsolation.storage_to_form() --> %s" % str(e)) + self.app.log.error("ToolIsolation.storage_to_form() --> %s" % str(e)) pass def form_to_storage(self): @@ -973,7 +974,7 @@ class ToolIsolation(AppTool, Gerber): def on_apply_param_to_all_clicked(self): if self.ui.tools_table.rowCount() == 0: # there is no tool in tool table so we can't save the GUI elements values to storage - log.debug("ToolIsolation.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") + self.app.log.debug("ToolIsolation.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") return self.blockSignals(True) @@ -1223,7 +1224,7 @@ class ToolIsolation(AppTool, Gerber): # reset the value to prepare for another isolation self.safe_tooldia = None except Exception as ee: - log.error(str(ee)) + self.app.log.error(str(ee)) return self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) @@ -1319,7 +1320,7 @@ class ToolIsolation(AppTool, Gerber): (_("Optimal tool diameter found"), str(min_dist_truncated), self.units.lower())) except Exception as ee: - log.error(str(ee)) + self.app.log.error(str(ee)) return self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) @@ -1592,7 +1593,7 @@ class ToolIsolation(AppTool, Gerber): self.ui_connect() return except Exception as e: - log.error(str(e)) + self.app.log.error(str(e)) self.app.inform.emit('[success] %s' % _("Tool(s) deleted from Tool Table.")) self.build_ui() @@ -3108,8 +3109,7 @@ class ToolIsolation(AppTool, Gerber): return 'fail' return geom - @staticmethod - def generate_rest_geometry(geometry, tooldia, passes, overlap, invert, env_iso_type=2, negative_dia=None, + def generate_rest_geometry(self, geometry, tooldia, passes, overlap, invert, env_iso_type=2, negative_dia=None, forced_rest=False, prog_plot="normal", prog_plot_handler=None, plot=False): """ @@ -3230,10 +3230,10 @@ class ToolIsolation(AppTool, Gerber): elif isinstance(work_geo_shp, LinearRing) and work_geo_shp is not None: work_geo_shp = [Polygon(work_geo_shp.coords[::-1])] else: - log.debug("ToolIsolation.generate_rest_geometry() Error --> Unexpected Geometry %s" % + self.app.log.debug("ToolIsolation.generate_rest_geometry() Error --> Unexpected Geometry %s" % type(work_geo)) except Exception as e: - log.error("ToolIsolation.generate_rest_geometry() Error --> %s" % str(e)) + self.app.log.error("ToolIsolation.generate_rest_geometry() Error --> %s" % str(e)) return 'fail', 'fail' actual_geo = work_geo_shp.geoms if isinstance(work_geo, MultiPolygon) else work_geo_shp diff --git a/appPlugins/ToolMarkers.py b/appPlugins/ToolMarkers.py index 8a462642..cc0c4ecc 100644 --- a/appPlugins/ToolMarkers.py +++ b/appPlugins/ToolMarkers.py @@ -318,7 +318,7 @@ class ToolMarkers(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolMarkers.add_markers() --> %s" % str(e)) + self.app.log.error("ToolMarkers.add_markers() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) self.app.call_source = "app" return @@ -353,7 +353,7 @@ class ToolMarkers(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolMarkers.add_markers() --> %s" % str(e)) + self.app.log.error("ToolMarkers.add_markers() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) self.on_exit() return @@ -413,7 +413,7 @@ class ToolMarkers(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolMarkers.add_markers() --> %s" % str(e)) + self.app.log.error("ToolMarkers.add_markers() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) self.on_exit() return @@ -748,7 +748,7 @@ class ToolMarkers(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolMarkers.add_markers() --> %s" % str(e)) + self.app.log.error("ToolMarkers.add_markers() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) self.app.call_source = "app" return @@ -857,7 +857,7 @@ class ToolMarkers(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("ToolMarkers.add_markers() --> %s" % str(e)) + self.app.log.error("ToolMarkers.add_markers() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) self.app.call_source = "app" return @@ -1037,7 +1037,7 @@ class ToolMarkers(AppTool): self.grb_object.options['xmax'] = c self.grb_object.options['ymax'] = d except Exception as e: - log.error("ToolMarkers.on_exit() copper_obj bounds error --> %s" % str(e)) + self.app.log.error("ToolMarkers.on_exit() copper_obj bounds error --> %s" % str(e)) self.app.call_source = "app" self.app.ui.notebook.setDisabled(False) diff --git a/appPlugins/ToolMove.py b/appPlugins/ToolMove.py index cf8c9021..a18e8d26 100644 --- a/appPlugins/ToolMove.py +++ b/appPlugins/ToolMove.py @@ -201,7 +201,7 @@ class ToolMove(AppTool): sel_obj.source_file = self.app.f_handlers.export_excellon( obj_name=out_name, filename=None, local_use=sel_obj, use_thread=False) except Exception as err: - log.error('[ERROR_NOTCL] %s --> %s' % ('ToolMove.on_left_click()', str(err))) + app_obj.log.error('[ERROR_NOTCL] %s --> %s' % ('ToolMove.on_left_click()', str(err))) return "fail" # time to plot the moved objects @@ -219,7 +219,7 @@ class ToolMove(AppTool): return except TypeError as e: - log.debug("ToolMove.on_left_click() --> %s" % str(e)) + self.app.log.debug("ToolMove.on_left_click() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] ToolMove. %s' % _('Error when mouse left click.')) return diff --git a/appPlugins/ToolNCC.py b/appPlugins/ToolNCC.py index e35f4e6a..febfa941 100644 --- a/appPlugins/ToolNCC.py +++ b/appPlugins/ToolNCC.py @@ -602,7 +602,7 @@ class NonCopperClear(AppTool, Gerber): else: return except Exception as e: - log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) + self.app.log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) return # update the QLabel that shows for which Tool we have the parameters in the UI form @@ -619,7 +619,7 @@ class NonCopperClear(AppTool, Gerber): if key == 'data': self.storage_to_form(tooluid_value['data']) except Exception as e: - log.error("NonCopperClear ---> update_ui() " + str(e)) + self.app.log.error("NonCopperClear ---> update_ui() " + str(e)) else: self.ui.tool_data_label.setText( "%s: %s" % (_('Parameters for'), _("Multiple Tools")) @@ -634,7 +634,7 @@ class NonCopperClear(AppTool, Gerber): try: self.form_fields[form_key].set_value(dict_storage[form_key]) except Exception as e: - log.error("NonCopperClear.storage_to_form() --> %s" % str(e)) + self.app.log.error("NonCopperClear.storage_to_form() --> %s" % str(e)) pass def form_to_storage(self): @@ -668,7 +668,7 @@ class NonCopperClear(AppTool, Gerber): def on_apply_param_to_all_clicked(self): if self.ui.tools_table.rowCount() == 0: # there is no tool in tool table so we can't save the GUI elements values to storage - log.debug("NonCopperClear.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") + self.app.log.debug("NonCopperClear.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") return self.blockSignals(True) @@ -1069,7 +1069,7 @@ class NonCopperClear(AppTool, Gerber): # reset the value to prepare for another isolation self.safe_tooldia = None except Exception as ee: - log.error(str(ee)) + self.app.log.error(str(ee)) return self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) @@ -1165,7 +1165,7 @@ class NonCopperClear(AppTool, Gerber): (_("Optimal tool diameter found"), str(min_dist_truncated), self.units.lower())) except Exception as ee: - log.error(str(ee)) + app_obj.log.error(str(ee)) return self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]}) @@ -1943,11 +1943,11 @@ class NonCopperClear(AppTool, Gerber): :return: an geometric element (Polygon or MultiPolygon) that specify the area to be copper cleared """ - log.debug("NCC Tool. Preparing non-copper polygons.") + self.app.log.debug("NCC Tool. Preparing non-copper polygons.") self.app.inform.emit(_("NCC Tool. Preparing non-copper polygons.")) if bbox is None: - log.debug("NonCopperClear.apply_margin_to_bounding_box() --> The object is None") + self.app.log.debug("NonCopperClear.apply_margin_to_bounding_box() --> The object is None") return 'fail' new_bounding_box = None @@ -1982,7 +1982,7 @@ class NonCopperClear(AppTool, Gerber): self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported.")) return 'fail' - log.debug("NCC Tool. Finished non-copper polygons.") + self.app.log.debug("NCC Tool. Finished non-copper polygons.") return new_bounding_box def get_tool_empty_area(self, name, ncc_obj, geo_obj, isotooldia, has_offset, ncc_offset, ncc_margin, @@ -2003,7 +2003,7 @@ class NonCopperClear(AppTool, Gerber): :return: """ - log.debug("NCC Tool. Calculate 'empty' area.") + self.app.log.debug("NCC Tool. Calculate 'empty' area.") self.app.inform.emit(_("NCC Tool. Calculate 'empty' area.")) # a flag to signal that the isolation is broken by the bounding box in 'area' and 'box' cases @@ -2026,7 +2026,7 @@ class NonCopperClear(AppTool, Gerber): if type(empty) is Polygon: empty = MultiPolygon([empty]) - log.debug("NCC Tool. Finished calculation of 'empty' area.") + self.app.log.debug("NCC Tool. Finished calculation of 'empty' area.") self.app.inform.emit(_("NCC Tool. Finished calculation of 'empty' area.")) return empty, warning_flag @@ -2176,7 +2176,7 @@ class NonCopperClear(AppTool, Gerber): if type(empty) is Polygon: empty = MultiPolygon([empty]) - log.debug("NCC Tool. Finished calculation of 'empty' area.") + self.app.log.debug("NCC Tool. Finished calculation of 'empty' area.") self.app.inform.emit(_("NCC Tool. Finished calculation of 'empty' area.")) return empty, warning_flag @@ -2284,7 +2284,7 @@ class NonCopperClear(AppTool, Gerber): :type run_threaded: bool :return: """ - log.debug("Executing the handler ...") + self.app.log.debug("Executing the clear_copper handler ...") if run_threaded: proc = self.app.proc_container.new('%s...' % _("Non-Copper Clearing")) @@ -2322,7 +2322,7 @@ class NonCopperClear(AppTool, Gerber): # ######### #####Initializes the new geometry object ##################################################### # ######################################################################################################## def gen_clear_area(geo_obj, app_obj): - log.debug("NCC Tool. Normal copper clearing task started.") + app_obj.log.debug("NCC Tool. Normal copper clearing task started.") self.app.inform.emit(_("NCC Tool. Finished non-copper polygons. Normal copper clearing task started.")) # provide the app with a way to process the GUI events when in a blocking loop @@ -2512,7 +2512,8 @@ class NonCopperClear(AppTool, Gerber): _("with diameter"), str(uid_val['tooldia'])) self.app.inform.emit(msg) - log.debug("Empty geometry for tool: %s with diameter: %s" % (str(uid), str(uid_val['tooldia']))) + self.app.log.debug( + "Empty geometry for tool: %s with diameter: %s" % (str(uid), str(uid_val['tooldia']))) tools_storage.pop(uid, None) except KeyError: tools_storage.pop(uid, None) @@ -2569,7 +2570,7 @@ class NonCopperClear(AppTool, Gerber): # Initializes the new geometry object for the case of the rest-machining #################### # ########################################################################################### def gen_clear_area_rest(geo_obj, app_obj): - log.debug("NCC Tool. Rest machining copper clearing task started.") + app_obj.log.debug("NCC Tool. Rest machining copper clearing task started.") app_obj.inform.emit(_("NCC Tool. Rest machining copper clearing task started.")) # provide the app with a way to process the GUI events when in a blocking loop @@ -2726,11 +2727,11 @@ class NonCopperClear(AppTool, Gerber): tools_storage[tool_uid]["data"]["name"] = name + '_' + str(tool) geo_obj.tools[tool_uid] = dict(tools_storage[tool_uid]) else: - log.debug("There are no geometries in the cleared polygon.") + app_obj.log.debug("There are no geometries in the cleared polygon.") - log.warning("Total number of polygons failed to be cleared: %s" % str(poly_failed)) + app_obj.log.warning("Total number of polygons failed to be cleared: %s" % str(poly_failed)) else: - log.warning("The area to be cleared has no polygons.") + app_obj.log.warning("The area to be cleared has no polygons.") # # Area to clear next # try: @@ -2889,7 +2890,7 @@ class NonCopperClear(AppTool, Gerber): units = self.app.app_units - log.debug("NCC Tool started. Reading parameters.") + self.app.log.debug("NCC Tool started. Reading parameters.") self.app.inform.emit(_("NCC Tool started. Reading parameters.")) ncc_method = method @@ -2928,7 +2929,7 @@ class NonCopperClear(AppTool, Gerber): # ############################################################################################################## # Prepare non-copper polygons. Create the bounding box area from which the copper features will be subtracted ## # ############################################################################################################## - log.debug("NCC Tool. Preparing non-copper polygons.") + self.app.log.debug("NCC Tool. Preparing non-copper polygons.") self.app.inform.emit(_("NCC Tool. Preparing non-copper polygons.")) try: @@ -2993,7 +2994,7 @@ class NonCopperClear(AppTool, Gerber): self.app.inform.emit('[ERROR_NOTCL] %s' % _("The reference object type is not supported.")) return 'fail' - log.debug("NCC Tool. Finished non-copper polygons.") + self.app.log.debug("NCC Tool. Finished non-copper polygons.") # ######################################################################################################## # set the name for the future Geometry object # I do it here because it is also stored inside the gen_clear_area() and gen_clear_area_rest() methods @@ -3015,7 +3016,7 @@ class NonCopperClear(AppTool, Gerber): if not run_threaded: QtWidgets.QApplication.processEvents() - log.debug("NCC Tool. Normal copper clearing task started.") + self.app.log.debug("NCC Tool. Normal copper clearing task started.") self.app.inform.emit(_("NCC Tool. Finished non-copper polygons. Normal copper clearing task started.")) # a flag to signal that the isolation is broken by the bounding box in 'area' and 'box' cases @@ -3047,7 +3048,7 @@ class NonCopperClear(AppTool, Gerber): # ################################################################################################### # Calculate the empty area by subtracting the solid_geometry from the object bounding box geometry ## # ################################################################################################### - log.debug("NCC Tool. Calculate 'empty' area.") + self.app.log.debug("NCC Tool. Calculate 'empty' area.") self.app.inform.emit(_("NCC Tool. Calculate 'empty' area.")) if ncc_obj.kind == 'gerber' and not isotooldia: @@ -3200,7 +3201,7 @@ class NonCopperClear(AppTool, Gerber): if type(empty) is Polygon: empty = MultiPolygon([empty]) - log.debug("NCC Tool. Finished calculation of 'empty' area.") + self.app.log.debug("NCC Tool. Finished calculation of 'empty' area.") self.app.inform.emit(_("NCC Tool. Finished calculation of 'empty' area.")) tool = 1 @@ -3283,10 +3284,11 @@ class NonCopperClear(AppTool, Gerber): poly_processed.append(True) else: poly_processed.append(False) - log.warning("Polygon in MultiPolygon can not be cleared.") + self.app.log.warning("Polygon in MultiPolygon can not be cleared.") else: - log.warning("Geo in Iterable can not be cleared because it is not Polygon. " - "It is: %s" % str(type(pol))) + self.app.log.warning( + "Geo in Iterable can not be cleared because it is not Polygon. " + "It is: %s" % str(type(pol))) except TypeError: if isinstance(p, Polygon): if ncc_method == 0: # standard @@ -3306,7 +3308,7 @@ class NonCopperClear(AppTool, Gerber): poly_processed.append(True) else: poly_processed.append(False) - log.warning("Polygon can not be cleared.") + self.app.log.warning("Polygon can not be cleared.") else: self.app.log.warning("Geo can not be cleared because it is: %s" % str(type(p))) @@ -3351,7 +3353,7 @@ class NonCopperClear(AppTool, Gerber): break geo_obj.tools[current_uid] = dict(tools_storage[current_uid]) else: - log.debug("There are no geometries in the cleared polygon.") + app_obj.log.debug("There are no geometries in the cleared polygon.") # delete tools with empty geometry # look for keys in the tools_storage dict that have 'solid_geometry' values empty @@ -3415,7 +3417,7 @@ class NonCopperClear(AppTool, Gerber): assert geo_obj.kind == 'geometry', \ "Initializer expected a GeometryObject, got %s" % type(geo_obj) - log.debug("NCC Tool. Rest machining copper clearing task started.") + app_obj.log.debug("NCC Tool. Rest machining copper clearing task started.") app_obj.inform.emit('_(NCC Tool. Rest machining copper clearing task started.') # provide the app with a way to process the GUI events when in a blocking loop @@ -3439,7 +3441,7 @@ class NonCopperClear(AppTool, Gerber): # repurposed flag for final object, geo_obj. True if it has any solid_geometry, False if not. app_obj.poly_not_cleared = True - log.debug("NCC Tool. Calculate 'empty' area.") + app_obj.log.debug("NCC Tool. Calculate 'empty' area.") app_obj.inform.emit("NCC Tool. Calculate 'empty' area.") # ################################################################################################### @@ -3588,7 +3590,7 @@ class NonCopperClear(AppTool, Gerber): area = empty.buffer(0) - log.debug("NCC Tool. Finished calculation of 'empty' area.") + app_obj.log.debug("NCC Tool. Finished calculation of 'empty' area.") app_obj.inform.emit("NCC Tool. Finished calculation of 'empty' area.") # Generate area for each tool @@ -3760,7 +3762,7 @@ class NonCopperClear(AppTool, Gerber): geo_obj.tools[current_uid] = dict(tools_storage[current_uid]) else: - log.debug("There are no geometries in the cleared polygon.") + app_obj.log.debug("There are no geometries in the cleared polygon.") geo_obj.multigeo = True geo_obj.options["tools_mill_tooldia"] = str(tool) @@ -3918,8 +3920,8 @@ class NonCopperClear(AppTool, Gerber): elif isinstance(geom, LinearRing) and geom is not None: geom = Polygon(geom.coords[::-1]) else: - log.debug("NonCopperClear.generate_envelope() Error --> Unexpected Geometry %s" % - type(geom)) + self.app.log.debug("NonCopperClear.generate_envelope() Error --> Unexpected Geometry %s" % + type(geom)) except Exception as e: self.app.log.error("NonCopperClear.generate_envelope() Error --> %s" % str(e)) return 'fail' diff --git a/appPlugins/ToolOptimal.py b/appPlugins/ToolOptimal.py index 7de150a6..0e44febb 100644 --- a/appPlugins/ToolOptimal.py +++ b/appPlugins/ToolOptimal.py @@ -219,7 +219,7 @@ class ToolOptimal(AppTool): try: fcobj = model_index.internalPointer().obj except Exception as e: - log.error("ToolOptimal.find_minimum_distance() --> %s" % str(e)) + self.app.log.error("ToolOptimal.find_minimum_distance() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return @@ -335,7 +335,7 @@ class ToolOptimal(AppTool): else: return 'fail' except Exception as e: - log.error("ToolOptimal.on_locate_position() --> first try %s" % str(e)) + self.app.log.error("ToolOptimal.on_locate_position() --> first try %s" % str(e)) self.app.inform.emit("[ERROR_NOTCL] The selected text is no valid location in the format " "((x0, y0), (x1, y1)).") return @@ -349,7 +349,7 @@ class ToolOptimal(AppTool): float('%.*f' % (self.decimals, (min(loc_1[1], loc_2[1]) + (abs(dy) / 2))))) self.app.on_jump_to(custom_location=loc) except Exception as e: - log.error("ToolOptimal.on_locate_position() --> sec try %s" % str(e)) + self.app.log.error("ToolOptimal.on_locate_position() --> sec try %s" % str(e)) return def on_update_text(self, data): @@ -448,7 +448,7 @@ class ToolOptimal(AppTool): else: return except Exception as e: - log.error("ToolOptimal.on_locate_sec_position() --> first try %s" % str(e)) + self.app.log.error("ToolOptimal.on_locate_sec_position() --> first try %s" % str(e)) self.app.inform.emit("[ERROR_NOTCL] The selected text is no valid location in the format " "((x0, y0), (x1, y1)).") return @@ -462,7 +462,7 @@ class ToolOptimal(AppTool): float('%.*f' % (self.decimals, (min(loc_1[1], loc_2[1]) + (abs(dy) / 2))))) self.app.on_jump_to(custom_location=loc) except Exception as e: - log.error("ToolOptimal.on_locate_sec_position() --> sec try %s" % str(e)) + self.app.log.error("ToolOptimal.on_locate_sec_position() --> sec try %s" % str(e)) return def reset_fields(self): diff --git a/appPlugins/ToolPDF.py b/appPlugins/ToolPDF.py index c94fa86f..0f2044d7 100644 --- a/appPlugins/ToolPDF.py +++ b/appPlugins/ToolPDF.py @@ -210,7 +210,7 @@ class ToolPDF(AppTool): if self.pdf_decompressed[short_name] == '': self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Failed to open"), str(filename))) - log.debug("ToolPDF.open_pdf().obj_init() --> Empty file or error on decompression") + self.app.log.debug("ToolPDF.open_pdf().obj_init() --> Empty file or error on decompression") self.parsing_promises.remove(short_name) return @@ -226,7 +226,7 @@ class ToolPDF(AppTool): self.parsing_promises.remove(short_name) time.sleep(0.1) except Exception as e: - log.error("ToolPDF.open_pdf() --> %s" % str(e)) + self.app.log.error("ToolPDF.open_pdf() --> %s" % str(e)) self.app.inform.emit('[success] %s: %s' % (_("Opened"), str(filename))) def layer_rendering_as_excellon(self, filename, ap_dict, layer_nr): @@ -276,7 +276,7 @@ class ToolPDF(AppTool): ret = new_obj.create_geometry() if ret == 'fail': - log.debug("Could not create geometry for Excellon object.") + self.app.log.debug("Could not create geometry for Excellon object.") return "fail" new_obj.source_file = app_obj.f_handlers.export_excellon(obj_name=outname, local_use=new_obj, @@ -382,7 +382,7 @@ class ToolPDF(AppTool): # self.plot_thread = threading.Thread(target=lambda: self.check_plot_finished(check_period)) # self.plot_thread.start() - log.debug("ToolPDF --> Periodic Check started.") + self.app.log.debug("ToolPDF --> Periodic Check started.") try: self.check_thread.stop() @@ -408,7 +408,7 @@ class ToolPDF(AppTool): try: if not self.parsing_promises: self.check_thread.stop() - log.debug("PDF --> start rendering") + self.app.log.debug("PDF --> start rendering") # parsing finished start the layer rendering if self.pdf_parsed: obj_to_delete = [] @@ -441,6 +441,6 @@ class ToolPDF(AppTool): if obj_name in self.pdf_parsed: self.pdf_parsed.pop(obj_name) - log.debug("ToolPDF --> Periodic check finished.") + self.app.log.debug("ToolPDF --> Periodic check finished.") except Exception: traceback.print_exc() diff --git a/appPlugins/ToolPaint.py b/appPlugins/ToolPaint.py index 0cb45e5d..5c94ad15 100644 --- a/appPlugins/ToolPaint.py +++ b/appPlugins/ToolPaint.py @@ -392,7 +392,8 @@ class ToolPaint(AppTool, Gerber): diameters = self.app.defaults["tools_paint_tooldia"] if not diameters: - log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> Plugins -> NCC Tools.") + self.app.log.error( + "At least one tool diameter needed. Verify in Edit -> Preferences -> Plugins -> NCC Tools.") self.build_ui() # if the Paint Method is "Single" disable the tool table context menu @@ -579,7 +580,7 @@ class ToolPaint(AppTool, Gerber): return 'fail' tooluid = int(item.text()) except Exception as e: - log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) + self.app.log.error("Tool missing. Add a tool in the Tool Table. %s" % str(e)) return # update the QLabel that shows for which Tool we have the parameters in the UI form @@ -595,7 +596,7 @@ class ToolPaint(AppTool, Gerber): if int(tooluid_key) == tooluid: self.storage_to_form(tooluid_value['data']) except Exception as e: - log.error("ToolPaint ---> update_ui() " + str(e)) + self.app.log.error("ToolPaint ---> update_ui() " + str(e)) else: self.ui.tool_data_label.setText( "%s: %s" % (_('Parameters for'), _("Multiple Tools")) @@ -608,7 +609,7 @@ class ToolPaint(AppTool, Gerber): try: self.form_fields[k].set_value(dict_storage[k]) except Exception as err: - log.error("ToolPaint.storage.form() --> %s" % str(err)) + self.app.log.error("ToolPaint.storage.form() --> %s" % str(err)) def form_to_storage(self): if self.ui.tools_table.rowCount() == 0: @@ -641,7 +642,7 @@ class ToolPaint(AppTool, Gerber): def on_apply_param_to_all_clicked(self): if self.ui.tools_table.rowCount() == 0: # there is no tool in tool table so we can't save the GUI elements values to storage - log.debug("NonCopperClear.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") + self.app.log.debug("NonCopperClear.on_apply_param_to_all_clicked() --> no tool in Tools Table, aborting.") return self.blockSignals(True) @@ -1116,7 +1117,7 @@ class ToolPaint(AppTool, Gerber): self.blockSignals(False) return except Exception as e: - log.error(str(e)) + self.app.log.error(str(e)) self.app.inform.emit('[success] %s' % _("Tool(s) deleted from Tool Table.")) self.blockSignals(False) @@ -1149,7 +1150,7 @@ class ToolPaint(AppTool, Gerber): try: self.paint_obj = self.app.collection.get_by_name(str(self.obj_name)) except Exception as e: - log.error("ToolPaint.on_paint_button_click() --> %s" % str(e)) + self.app.log.error("ToolPaint.on_paint_button_click() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name)) return @@ -1571,7 +1572,7 @@ class ToolPaint(AppTool, Gerber): self.app.plotcanvas.graph_event_disconnect(self.mm) self.app.plotcanvas.graph_event_disconnect(self.kp) except Exception as e: - log.error("ToolPaint.on_key_press() _1 --> %s" % str(e)) + self.app.log.error("ToolPaint.on_key_press() _1 --> %s" % str(e)) self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot) @@ -1595,7 +1596,7 @@ class ToolPaint(AppTool, Gerber): self.app.tool_shapes.clear(update=True) except Exception as e: - log.error("ToolPaint.on_key_press() _2 --> %s" % str(e)) + self.app.log.error("ToolPaint.on_key_press() _2 --> %s" % str(e)) self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) @@ -1627,7 +1628,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Standard --> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Standard --> %s" % str(ee)) elif paint_method == 1: # _("Seed") try: # Type(cp) == FlatCAMRTreeStorage | None @@ -1641,7 +1642,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Seed --> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Seed --> %s" % str(ee)) elif paint_method == 2: # _("Lines") try: # Type(cp) == FlatCAMRTreeStorage | None @@ -1655,7 +1656,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Lines --> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Lines --> %s" % str(ee)) elif paint_method == 3: # _("Laser_lines") # line = None # aperture_size = None @@ -1702,7 +1703,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Identify flashes/traces--> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Identify flashes/traces--> %s" % str(ee)) cpoly = FlatCAMRTreeStorage() pads_lines_list = [] @@ -1750,7 +1751,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Process flashes--> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Process flashes--> %s" % str(ee)) # add the lines from pads to the storage try: @@ -1782,7 +1783,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Process traces--> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Laser Lines -> Process traces--> %s" % str(ee)) # add the lines from copper features to storage but first try to make as few lines as possible # by trying to fuse them @@ -1830,7 +1831,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as ee: - log.error("ToolPaint.paint_polygon_worker() Combo --> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_polygon_worker() Combo --> %s" % str(ee)) if cpoly and cpoly.objects: return cpoly @@ -1910,7 +1911,7 @@ class ToolPaint(AppTool, Gerber): pass for tool_dia in sorted_tools: - log.debug("Starting geometry processing for tool: %s" % str(tool_dia)) + self.app.log.debug("Starting geometry processing for tool: %s" % str(tool_dia)) msg = '[success] %s %s%s %s' % (_('Painting with tool diameter = '), str(tool_dia), self.units.lower(), @@ -1947,7 +1948,7 @@ class ToolPaint(AppTool, Gerber): # variables to display the percentage of work done geo_len = len(poly_buf) - log.warning("Total number of polygons to be cleared. %s" % str(geo_len)) + self.app.log.warning("Total number of polygons to be cleared. %s" % str(geo_len)) pol_nr = 0 @@ -2000,7 +2001,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as e: - log.error("Could not Paint the polygons. %s" % str(e)) + self.app.log.error("Could not Paint the polygons. %s" % str(e)) mssg = '[ERROR] %s\n%s' % (_("Could not do Paint. Try a different combination of parameters. " "Or a different method of Paint"), str(e)) self.app.inform.emit(mssg) @@ -2045,7 +2046,7 @@ class ToolPaint(AppTool, Gerber): geo_obj.options['xmax'] = c geo_obj.options['ymax'] = d except Exception as ee: - log.error("ToolPaint.paint_poly.job_init() bounds error --> %s" % str(ee)) + self.app.log.error("ToolPaint.paint_poly.job_init() bounds error --> %s" % str(ee)) return # test if at least one tool has solid_geometry. If no tool has solid_geometry we raise an Exception @@ -2096,10 +2097,10 @@ class ToolPaint(AppTool, Gerber): # variables to display the percentage of work done geo_len = len(poly_buf) - log.warning("Total number of polygons to be cleared. %s" % str(geo_len)) + self.app.log.warning("Total number of polygons to be cleared. %s" % str(geo_len)) for tool_dia in sorted_tools: - log.debug("Starting geometry processing for tool: %s" % str(tool_dia)) + self.app.log.debug("Starting geometry processing for tool: %s" % str(tool_dia)) msg = '[success] %s %s%s %s' % (_('Painting with tool diameter = '), str(tool_dia), self.units.lower(), @@ -2210,7 +2211,7 @@ class ToolPaint(AppTool, Gerber): except grace: return "fail" except Exception as e: - log.error("Could not Paint the polygons. %s" % str(e)) + self.app.log.error("Could not Paint the polygons. %s" % str(e)) msg = '[ERROR] %s\n%s' % (_("Could not do Paint. Try a different combination of parameters. " "Or a different method of Paint"), str(e)) self.app.inform.emit(msg) @@ -2225,10 +2226,10 @@ class ToolPaint(AppTool, Gerber): tools_storage[current_uid]['data']['name'] = name geo_obj.tools[current_uid] = dict(tools_storage[current_uid]) else: - log.debug("There are no geometries in the cleared polygon.") + self.app.log.debug("There are no geometries in the cleared polygon.") # Area to clear next - log.debug("Generating rest geometry for the next tool.") + self.app.log.debug("Generating rest geometry for the next tool.") buffered_cleared = unary_union(cleared_geo) buffered_cleared = buffered_cleared.buffer(tool_dia / 2.0) @@ -2250,7 +2251,7 @@ class ToolPaint(AppTool, Gerber): poly_buf = unary_union(tmp) if not poly_buf or poly_buf.is_empty or not poly_buf.is_valid: - log.debug("Rest geometry empty. Breaking.") + app_obj.log.debug("Rest geometry empty. Breaking.") break geo_obj.multigeo = True @@ -2301,7 +2302,7 @@ class ToolPaint(AppTool, Gerber): geo_obj.options['xmax'] = c geo_obj.options['ymax'] = d except Exception as ee: - log.error("ToolPaint.paint_poly.job_init() bounds error --> %s" % str(ee)) + app_obj.log.error("ToolPaint.paint_poly.job_init() bounds error --> %s" % str(ee)) return # Experimental... @@ -2638,7 +2639,7 @@ class ToolPaint(AppTool, Gerber): env_obj = env_obj.convex_hull sel_rect = env_obj.buffer(distance=0.0000001, join_style=base.JOIN_STYLE.mitre) except Exception as e: - log.error("ToolPaint.paint_poly_ref() --> %s" % str(e)) + self.app.log.error("ToolPaint.paint_poly_ref() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s' % _("No object available.")) return @@ -2780,7 +2781,7 @@ class ToolPaint(AppTool, Gerber): try: minx_, miny_, maxx_, maxy_ = bounds_rec(k) except Exception as e: - log.error("ToolPaint.bounds() --> %s" % str(e)) + # log.error("ToolPaint.bounds() --> %s" % str(e)) return minx = min(minx, minx_) diff --git a/appPlugins/ToolPanelize.py b/appPlugins/ToolPanelize.py index 783c371e..4644d888 100644 --- a/appPlugins/ToolPanelize.py +++ b/appPlugins/ToolPanelize.py @@ -316,7 +316,7 @@ class Panelize(AppTool): try: panel_source_obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("Panelize.on_panelize() --> %s" % str(e)) + self.app.log.error("Panelize.on_panelize() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), name)) return @@ -330,7 +330,7 @@ class Panelize(AppTool): try: box = self.app.collection.get_by_name(boxname) except Exception as e: - log.error("Panelize.on_panelize() --> %s" % str(e)) + self.app.log.error("Panelize.on_panelize() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), boxname)) return @@ -423,7 +423,7 @@ class Panelize(AppTool): try: obj_fin.options[option] = panel_source_obj.options[option] except KeyError: - log.warning("Failed to copy option. %s" % str(option)) + app_obj.log.warning("Failed to copy option. %s" % str(option)) # calculate the total number of drills and slots geo_len_drills = 0 diff --git a/appPlugins/ToolPunchGerber.py b/appPlugins/ToolPunchGerber.py index a127f6e8..489eeb92 100644 --- a/appPlugins/ToolPunchGerber.py +++ b/appPlugins/ToolPunchGerber.py @@ -1814,7 +1814,7 @@ class ToolPunchGerber(AppTool, Gerber): self.app.plotcanvas.graph_event_disconnect(self.mm) self.app.plotcanvas.graph_event_disconnect(self.kp) except Exception as e: - log.error("ToolPaint.on_key_press() _1 --> %s" % str(e)) + self.app.log.error("ToolPaint.on_key_press() _1 --> %s" % str(e)) self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot) @@ -1838,7 +1838,7 @@ class ToolPunchGerber(AppTool, Gerber): self.app.tool_shapes.clear(update=True) except Exception as e: - log.error("ToolPaint.on_key_press() _2 --> %s" % str(e)) + self.app.log.error("ToolPaint.on_key_press() _2 --> %s" % str(e)) self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) diff --git a/appPlugins/ToolQRCode.py b/appPlugins/ToolQRCode.py index 7fc4ffda..cf2a0b86 100644 --- a/appPlugins/ToolQRCode.py +++ b/appPlugins/ToolQRCode.py @@ -240,7 +240,7 @@ class QRCode(AppTool): try: self.grb_object = model_index.internalPointer().obj except Exception as e: - log.error("QRCode.execute() --> %s" % str(e)) + self.app.log.error("QRCode.execute() --> %s" % str(e)) self.app.inform.emit('[WARNING_NOTCL] %s' % _("There is no Gerber object loaded ...")) return @@ -286,7 +286,7 @@ class QRCode(AppTool): a, b, c, d = self.qrcode_utility_geometry.bounds self.box_poly = box(minx=a, miny=b, maxx=c, maxy=d) except Exception as ee: - log.error("QRCode.make() bounds error --> %s" % str(ee)) + self.app.log.error("QRCode.make() bounds error --> %s" % str(ee)) app_obj.call_source = 'qrcode_tool' app_obj.inform.emit(_("Click on the DESTINATION point ...")) @@ -388,7 +388,7 @@ class QRCode(AppTool): self.grb_object.options['xmax'] = c self.grb_object.options['ymax'] = d except Exception as e: - log.error("QRCode.make() bounds error --> %s" % str(e)) + self.app.log.error("QRCode.make() bounds error --> %s" % str(e)) try: for geo in self.qrcode_geometry: diff --git a/appPlugins/ToolReport.py b/appPlugins/ToolReport.py index 1afddc5c..985babb4 100644 --- a/appPlugins/ToolReport.py +++ b/appPlugins/ToolReport.py @@ -148,7 +148,7 @@ class ObjectReport(AppTool): try: self.app.delete_selection_shape() except Exception as e: - log.error("ToolReport.Properties.properties() --> %s" % str(e)) + self.app.log.error("ToolReport.Properties.properties() --> %s" % str(e)) # populate the properties items for obj in obj_list: @@ -216,7 +216,7 @@ class ObjectReport(AppTool): ], True) except Exception as e: - log.error("Properties.addItems() --> %s" % str(e)) + self.app.log.error("Properties.addItems() --> %s" % str(e)) self.treeWidget.addChild(obj_name, [obj.options['name']]) @@ -237,7 +237,7 @@ class ObjectReport(AppTool): length = abs(xmax - xmin) width = abs(ymax - ymin) except Exception as ee: - log.error("PropertiesTool.addItems() -> calculate dimensions --> %s" % str(ee)) + self.app.log.error("PropertiesTool.addItems() -> calculate dimensions --> %s" % str(ee)) # calculate box area if self.app.app_units.lower() == 'mm': @@ -269,7 +269,7 @@ class ObjectReport(AppTool): xmax.append(x1) ymax.append(y1) except Exception as ee: - log.error("PropertiesTool.addItems() --> %s" % str(ee)) + self.app.log.error("PropertiesTool.addItems() --> %s" % str(ee)) try: for tool_k in obj_prop.tools: @@ -279,7 +279,7 @@ class ObjectReport(AppTool): xmax.append(x1) ymax.append(y1) except Exception as ee: - log.error("PropertiesTool.addItems() --> %s" % str(ee)) + self.app.log.error("PropertiesTool.addItems() --> %s" % str(ee)) else: try: for tool_k in obj_prop.tools: @@ -289,7 +289,7 @@ class ObjectReport(AppTool): xmax.append(x1) ymax.append(y1) except Exception as ee: - log.error("PropertiesTool.addItems() --> %s" % str(ee)) + self.app.log.error("PropertiesTool.addItems() --> %s" % str(ee)) try: xmin = min(xmin) @@ -323,7 +323,7 @@ class ObjectReport(AppTool): copper_area += geo_tools.area copper_area /= 100 except Exception as err: - log.error("Properties.addItems() --> %s" % str(err)) + self.app.log.error("Properties.addItems() --> %s" % str(err)) area_chull = 0.0 if obj_prop.kind.lower() != 'cncjob': @@ -352,7 +352,7 @@ class ObjectReport(AppTool): area_chull = max(area_chull) except Exception as er: area_chull = None - log.error("Properties.addItems() --> %s" % str(er)) + self.app.log.error("Properties.addItems() --> %s" % str(er)) if self.app.app_units.lower() == 'mm' and area_chull: area_chull = area_chull / 100 diff --git a/appPlugins/ToolRulesCheck.py b/appPlugins/ToolRulesCheck.py index e3e9a1e4..4fdf4762 100644 --- a/appPlugins/ToolRulesCheck.py +++ b/appPlugins/ToolRulesCheck.py @@ -190,7 +190,7 @@ class RulesCheck(AppTool): @staticmethod def check_inside_gerber_clearance(gerber_obj, size, rule): - log.debug("RulesCheck.check_inside_gerber_clearance()") + # log.debug("RulesCheck.check_inside_gerber_clearance()") rule_title = rule @@ -233,7 +233,7 @@ class RulesCheck(AppTool): else: iterations = len(total_geo) iterations = (iterations * (iterations - 1)) / 2 - log.debug("RulesCheck.check_gerber_clearance(). Iterations: %s" % str(iterations)) + # log.debug("RulesCheck.check_gerber_clearance(). Iterations: %s" % str(iterations)) min_dict = {} idx = 1 @@ -265,7 +265,7 @@ class RulesCheck(AppTool): @staticmethod def check_gerber_clearance(gerber_list, size, rule): - log.debug("RulesCheck.check_gerber_clearance()") + # log.debug("RulesCheck.check_gerber_clearance()") rule_title = rule violations = [] @@ -332,7 +332,7 @@ class RulesCheck(AppTool): len_3 = len(total_geo_grb_3) iterations = len_1 * len_3 - log.debug("RulesCheck.check_gerber_clearance(). Iterations: %s" % str(iterations)) + # log.debug("RulesCheck.check_gerber_clearance(). Iterations: %s" % str(iterations)) min_dict = {} for geo in total_geo_grb_1: @@ -372,7 +372,7 @@ class RulesCheck(AppTool): @staticmethod def check_holes_size(elements, size): - log.debug("RulesCheck.check_holes_size()") + # log.debug("RulesCheck.check_holes_size()") rule = _("Hole Size") @@ -399,7 +399,7 @@ class RulesCheck(AppTool): @staticmethod def check_holes_clearance(elements, size): - log.debug("RulesCheck.check_holes_clearance()") + # log.debug("RulesCheck.check_holes_clearance()") rule = _("Hole to Hole Clearance") violations = [] @@ -454,7 +454,7 @@ class RulesCheck(AppTool): @staticmethod def check_traces_size(elements, size): - log.debug("RulesCheck.check_traces_size()") + # log.debug("RulesCheck.check_traces_size()") rule = _("Trace Size") @@ -584,7 +584,7 @@ class RulesCheck(AppTool): len_2 = len(total_geo_exc) iterations = len_1 * len_2 - log.debug("RulesCheck.check_gerber_annular_ring(). Iterations: %s" % str(iterations)) + # log.debug("RulesCheck.check_gerber_annular_ring(). Iterations: %s" % str(iterations)) min_dict = {} dist = None @@ -594,7 +594,8 @@ class RulesCheck(AppTool): # minimize the number of distances by not taking into considerations those that are too small dist = abs(geo.exterior.distance(s_geo)) except Exception as e: - log.error("RulesCheck.check_gerber_annular_ring() --> %s" % str(e)) + # log.error("RulesCheck.check_gerber_annular_ring() --> %s" % str(e)) + pass if dist > 0: if float(dist) < float(size): @@ -651,7 +652,7 @@ class RulesCheck(AppTool): def execute(self): self.results = [] - log.debug("RuleCheck() executing") + self.app.log.debug("RuleCheck() executing") def worker_job(app_obj): # self.app.proc_container.new(_("Working...")) @@ -685,7 +686,7 @@ class RulesCheck(AppTool): try: copper_copper_clearance = float(self.ui.clearance_copper2copper_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + self.app.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Copper to Copper clearance"), _("Value is not valid."))) @@ -745,7 +746,7 @@ class RulesCheck(AppTool): try: copper_outline_clearance = float(self.ui.clearance_copper2ol_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + app_obj.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) app_obj.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Copper to Outline clearance"), _("Value is not valid."))) @@ -782,7 +783,7 @@ class RulesCheck(AppTool): try: silk_silk_clearance = float(self.ui.clearance_silk2silk_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + app_obj.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) app_obj.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Silk to Silk clearance"), _("Value is not valid."))) @@ -854,7 +855,7 @@ class RulesCheck(AppTool): try: silk_sm_clearance = float(self.ui.clearance_silk2sm_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + app_obj.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) app_obj.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Silk to Solder Mask Clearance"), _("Value is not valid."))) @@ -908,7 +909,7 @@ class RulesCheck(AppTool): try: copper_outline_clearance = float(self.ui.clearance_copper2ol_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + app_obj.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) app_obj.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Silk to Outline Clearance"), _("Value is not valid."))) @@ -946,7 +947,7 @@ class RulesCheck(AppTool): try: sm_sm_clearance = float(self.ui.clearance_sm2sm_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + app_obj.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) app_obj.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Minimum Solder Mask Sliver"), _("Value is not valid."))) @@ -1011,7 +1012,7 @@ class RulesCheck(AppTool): try: ring_val = float(self.ui.ring_integrity_entry.get_value()) except Exception as e: - log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) + app_obj.log.error("RulesCheck.execute.worker_job() --> %s" % str(e)) app_obj.inform.emit('[ERROR_NOTCL] %s. %s' % ( _("Minimum Annular Ring"), _("Value is not valid."))) @@ -1095,7 +1096,7 @@ class RulesCheck(AppTool): self.tool_finished.emit(output) app_obj.proc_container.view.set_idle() - log.debug("RuleCheck() finished") + self.app.log.debug("RuleCheck() finished") self.app.worker_task.emit({'fcn': worker_job, 'params': [self.app]}) diff --git a/appPlugins/ToolSub.py b/appPlugins/ToolSub.py index f83f6dc6..44ad16d2 100644 --- a/appPlugins/ToolSub.py +++ b/appPlugins/ToolSub.py @@ -282,7 +282,7 @@ class ToolSub(AppTool): try: self.target_grb_obj = self.app.collection.get_by_name(self.target_grb_obj_name) except Exception as e: - log.error("ToolSub.on_subtract_gerber_click() --> %s" % str(e)) + self.app.log.error("ToolSub.on_subtract_gerber_click() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name)) return "Could not retrieve object: %s" % self.target_grb_obj_name @@ -300,7 +300,7 @@ class ToolSub(AppTool): try: self.sub_grb_obj = self.app.collection.get_by_name(self.sub_grb_obj_name) except Exception as e: - log.error("ToolSub.on_subtract_gerber_click() --> %s" % str(e)) + self.app.log.error("ToolSub.on_subtract_gerber_click() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name)) return "Could not retrieve object: %s" % self.sub_grb_obj_name @@ -514,7 +514,7 @@ class ToolSub(AppTool): try: self.target_geo_obj = self.app.collection.get_by_name(self.target_geo_obj_name) except Exception as e: - log.error("ToolSub.on_subtract_geo_click() --> %s" % str(e)) + self.app.log.error("ToolSub.on_subtract_geo_click() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.target_geo_obj_name)) return "Could not retrieve object: %s" % self.target_grb_obj_name @@ -527,7 +527,7 @@ class ToolSub(AppTool): try: self.sub_geo_obj = self.app.collection.get_by_name(self.sub_geo_obj_name) except Exception as e: - log.error("ToolSub.on_subtract_geo_click() --> %s" % str(e)) + self.app.log.error("ToolSub.on_subtract_geo_click() --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.sub_geo_obj_name)) return "Could not retrieve object: %s" % self.sub_geo_obj_name @@ -570,7 +570,7 @@ class ToolSub(AppTool): def toolgeo_intersection(self, tool, geo): new_geometry = [] - log.debug("Working on promise: %s" % str(tool)) + self.app.log.debug("Working on promise: %s" % str(tool)) if tool == "single": text = _("Parsing solid_geometry ...") @@ -644,7 +644,7 @@ class ToolSub(AppTool): self.promises.remove(tool) time.sleep(0.5) - log.debug("Promise fulfilled: %s" % str(tool)) + self.app.log.debug("Promise fulfilled: %s" % str(tool)) def new_geo_object(self, outname): geo_name = outname @@ -700,7 +700,7 @@ class ToolSub(AppTool): :return: """ - log.debug("ToolSub --> Periodic Check started.") + self.app.log.debug("ToolSub --> Periodic Check started.") try: self.check_thread.stop() @@ -732,10 +732,10 @@ class ToolSub(AppTool): # reset the type of substraction for next time self.sub_type = None - log.debug("ToolSub --> Periodic check finished.") + self.app.log.debug("ToolSub --> Periodic check finished.") except Exception as e: self.job_finished.emit(False) - log.error("ToolSub().periodic_check_handler() --> %s" % str(e)) + self.app.log.error("ToolSub().periodic_check_handler() --> %s" % str(e)) traceback.print_exc() def on_job_finished(self, succcess): diff --git a/camlib.py b/camlib.py index 2fe3eea5..0da8d1b8 100644 --- a/camlib.py +++ b/camlib.py @@ -599,7 +599,7 @@ class Geometry(object): try: self.solid_geometry = self.solid_geometry.union(new_circle) except Exception as e: - log.error("Failed to run union on polygons. %s" % str(e)) + self.app.log.error("Failed to run union on polygons. %s" % str(e)) return "fail" # add in tools solid_geometry @@ -640,7 +640,7 @@ class Geometry(object): try: self.solid_geometry = self.solid_geometry.union(Polygon(points)) except Exception as e: - log.error("Failed to run union on polygons. %s" % str(e)) + self.app.log.error("Failed to run union on polygons. %s" % str(e)) return "fail" # add in tools solid_geometry @@ -724,7 +724,7 @@ class Geometry(object): # pathonly should be allways True, otherwise polygons are not subtracted flat_geometry = self.flatten(pathonly=True) - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) if not isinstance(points, Polygon): polygon = Polygon(points) @@ -1179,7 +1179,7 @@ class Geometry(object): self.app.proc_container.update_view_text(' %s' % _("Get Interiors")) ret_geo = self.get_interiors(geo_iso) else: - log.debug("Geometry.isolation_geometry() --> Type of isolation not supported") + self.app.log.debug("Geometry.isolation_geometry() --> Type of isolation not supported") return "fail" if prog_plot == 'progressive': @@ -1323,7 +1323,7 @@ class Geometry(object): :param units: Application units :return: None """ - log.debug("Parsing DXF file geometry into a Geometry object solid geometry.") + self.app.log.debug("Parsing DXF file geometry into a Geometry object solid geometry.") # Parse into list of shapely objects dxf = ezdxf.readfile(filename) @@ -1492,7 +1492,7 @@ class Geometry(object): if prog_plot: self.plot_temp_shapes(i) else: - log.debug("camlib.Geometry.clear_polygon() --> Current Area is zero") + self.app.log.debug("camlib.Geometry.clear_polygon() --> Current Area is zero") break if prog_plot: @@ -1641,7 +1641,7 @@ class Geometry(object): # log.debug("camlib.clear_polygon3()") if not isinstance(polygon, Polygon): - log.debug("camlib.Geometry.clear_polygon3() --> Not a Polygon but %s" % str(type(polygon))) + self.app.log.debug("camlib.Geometry.clear_polygon3() --> Not a Polygon but %s" % str(type(polygon))) return None # ## The toolpaths @@ -1660,7 +1660,7 @@ class Geometry(object): try: margin_poly = polygon.buffer(-tooldia / 1.99999999, (int(steps_per_circle))) except Exception: - log.debug("camlib.Geometry.clear_polygon3() --> Could not buffer the Polygon") + self.app.log.debug("camlib.Geometry.clear_polygon3() --> Could not buffer the Polygon") return None # decide the direction of the lines @@ -1700,7 +1700,7 @@ class Geometry(object): if prog_plot: self.plot_temp_shapes(lines_geometry) except Exception as e: - log.error('camlib.Geometry.clear_polygon3() Processing poly --> %s' % str(e)) + self.app.log.error('camlib.Geometry.clear_polygon3() Processing poly --> %s' % str(e)) return None else: # First line @@ -1738,7 +1738,7 @@ class Geometry(object): if prog_plot: self.plot_temp_shapes(lines_geometry) except Exception as e: - log.error('camlib.Geometry.clear_polygon3() Processing poly --> %s' % str(e)) + self.app.log.error('camlib.Geometry.clear_polygon3() Processing poly --> %s' % str(e)) return None if prog_plot: @@ -1754,7 +1754,7 @@ class Geometry(object): if not line.is_empty: geoms.insert(line) else: - log.debug("camlib.Geometry.clear_polygon3(). Not a line: %s" % str(type(line))) + self.app.log.debug("camlib.Geometry.clear_polygon3(). Not a line: %s" % str(type(line))) except TypeError: # in case lines_trimmed are not iterable (Linestring, LinearRing) if not lines_trimmed.is_empty: @@ -1818,7 +1818,8 @@ class Geometry(object): # log.debug("camlib.fill_with_lines()") if not isinstance(line, LineString): - log.debug("camlib.Geometry.fill_with_lines() --> Not a LineString/MultiLineString but %s" % str(type(line))) + self.app.log.debug( + "camlib.Geometry.fill_with_lines() --> Not a LineString/MultiLineString but %s" % str(type(line))) return None # ## The toolpaths @@ -1870,7 +1871,8 @@ class Geometry(object): try: margin_poly = polygon.buffer(-tooldia / 2.0, int(steps_per_circle)) except Exception: - log.debug("camlib.Geometry.fill_with_lines() --> Could not buffer the Polygon, tool diameter too high") + self.app.log.debug( + "camlib.Geometry.fill_with_lines() --> Could not buffer the Polygon, tool diameter too high") return None # First line @@ -1903,7 +1905,7 @@ class Geometry(object): new_line = prepared_line.parallel_offset(distance=delta, side='left', resolution=int(steps_per_circle)) new_line = new_line.intersection(margin_poly) except Exception as e: - log.error('camlib.Geometry.fill_with_lines() Processing poly --> %s' % str(e)) + self.app.log.error('camlib.Geometry.fill_with_lines() Processing poly --> %s' % str(e)) return None lines_geometry = new_line.geoms if isinstance(new_line, MultiLineString) else new_line @@ -1943,7 +1945,7 @@ class Geometry(object): if isinstance(line_g, LineString) or isinstance(line_g, LinearRing): geoms.insert(line_g) else: - log.debug("camlib.Geometry.fill_with_lines(). Not a line: %s" % str(type(line_g))) + self.app.log.debug("camlib.Geometry.fill_with_lines(). Not a line: %s" % str(type(line_g))) except TypeError: # in case lines_trimmed are not iterable (Linestring, LinearRing) geoms.insert(lines_geometry) @@ -2130,7 +2132,7 @@ class Geometry(object): :rtype: FlatCAMRTreeStorage """ - log.debug("path_connect()") + # log.debug("path_connect()") # ## Index first and last points in paths def get_pts(o): @@ -2230,7 +2232,7 @@ class Geometry(object): optimized_geometry.insert(geo) # print path_count - log.debug("path_count = %d" % path_count) + # log.debug("path_count = %d" % path_count) return optimized_geometry @@ -2247,18 +2249,18 @@ class Geometry(object): """ if obj_units.upper() == self.units.upper(): - log.debug("camlib.Geometry.convert_units() --> Factor: 1") + self.app.log.debug("camlib.Geometry.convert_units() --> Factor: 1") return 1.0 if obj_units.upper() == "MM": factor = 25.4 - log.debug("camlib.Geometry.convert_units() --> Factor: 25.4") + self.app.log.debug("camlib.Geometry.convert_units() --> Factor: 25.4") elif obj_units.upper() == "IN": factor = 1 / 25.4 - log.debug("camlib.Geometry.convert_units() --> Factor: %s" % str(1 / 25.4)) + self.app.log.debug("camlib.Geometry.convert_units() --> Factor: %s" % str(1 / 25.4)) else: - log.error("Unsupported units: %s" % str(obj_units)) - log.debug("camlib.Geometry.convert_units() --> Factor: 1") + self.app.log.error("Unsupported units: %s" % str(obj_units)) + self.app.log.debug("camlib.Geometry.convert_units() --> Factor: 1") return 1.0 self.units = obj_units @@ -2406,7 +2408,7 @@ class Geometry(object): :type point: list :return: None """ - log.debug("camlib.Geometry.mirror()") + self.app.log.debug("camlib.Geometry.mirror()") px, py = point xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis] @@ -2474,7 +2476,7 @@ class Geometry(object): See shapely manual for more information: http://toblerity.org/shapely/manual.html#affine-transformations """ - log.debug("camlib.Geometry.rotate()") + self.app.log.debug("camlib.Geometry.rotate()") px, py = point @@ -2548,7 +2550,7 @@ class Geometry(object): See shapely manual for more information: http://toblerity.org/shapely/manual.html#affine-transformations """ - log.debug("camlib.Geometry.skew()") + self.app.log.debug("camlib.Geometry.skew()") px, py = point @@ -2618,7 +2620,7 @@ class Geometry(object): :return: """ - log.debug("camlib.Geometry.buffer()") + self.app.log.debug("camlib.Geometry.buffer()") if distance == 0: return @@ -2865,7 +2867,7 @@ class CNCjob(Geometry): :return: conversion factor :rtype: float """ - log.debug("camlib.CNCJob.convert_units()") + self.app.log.debug("camlib.CNCJob.convert_units()") factor = Geometry.convert_units(self, units) @@ -2929,7 +2931,7 @@ class CNCjob(Geometry): except AttributeError: self.app.inform.emit('[ERROR] %s: %s' % (_("There is no such parameter"), str(match))) - log.debug("CNCJob.parse_custom_toolchange_code() --> AttributeError ") + self.app.log.debug("CNCJob.parse_custom_toolchange_code() --> AttributeError ") return 'fail' text = text.replace(match, str(value)) return text @@ -2981,7 +2983,7 @@ class CNCjob(Geometry): # Create routing model. if tsp_size == 0: - log.warning('OR-tools metaheuristics - Specify an instance greater than 0.') + self.app.log.warning('OR-tools metaheuristics - Specify an instance greater than 0.') return optimized_path manager = pywrapcp.RoutingIndexManager(tsp_size, num_routes, depot) @@ -3030,7 +3032,7 @@ class CNCjob(Geometry): optimized_path.append(node) node = assignment.Value(routing.NextVar(node)) else: - log.warning('OR-tools metaheuristics - No solution found.') + self.app.log.warning('OR-tools metaheuristics - No solution found.') return optimized_path # ############################################# ## @@ -3046,7 +3048,7 @@ class CNCjob(Geometry): # Create routing model. if tsp_size == 0: - log.warning('Specify an instance greater than 0.') + self.app.log.warning('Specify an instance greater than 0.') return optimized_path manager = pywrapcp.RoutingIndexManager(tsp_size, num_routes, depot) @@ -3074,7 +3076,7 @@ class CNCjob(Geometry): if assignment: # Solution cost. - log.info("Total distance: " + str(assignment.ObjectiveValue())) + self.app.log.info("Total distance: " + str(assignment.ObjectiveValue())) # Inspect solution. # Only one route here; otherwise iterate from 0 to routing.vehicles() - 1. @@ -3086,7 +3088,7 @@ class CNCjob(Geometry): optimized_path.append(node) node = assignment.Value(routing.NextVar(node)) else: - log.warning('No solution found.') + self.app.log.warning('No solution found.') return optimized_path # ############################################# ## @@ -3142,7 +3144,7 @@ class CNCjob(Geometry): storage.get_points = get_pts # Store the geometry - log.debug("Indexing geometry before generating G-Code...") + self.app.log.debug("Indexing geometry before generating G-Code...") self.app.inform.emit(_("Indexing geometry before generating G-Code...")) work_geo = geometry.geoms if isinstance(geometry, (MultiPolygon, MultiLineString)) else geometry @@ -3186,7 +3188,7 @@ class CNCjob(Geometry): storage.get_points = get_pts # Store the geometry - log.debug("Indexing geometry before generating G-Code...") + self.app.log.debug("Indexing geometry before generating G-Code...") self.app.inform.emit(_("Indexing geometry before generating G-Code...")) for geo_shape in geometry: @@ -3273,20 +3275,20 @@ class CNCjob(Geometry): opt_type = 'R' if opt_type == 'M': - log.debug("Using OR-Tools Metaheuristic Guided Local Search drill path optimization.") + self.app.log.debug("Using OR-Tools Metaheuristic Guided Local Search drill path optimization.") elif opt_type == 'B': - log.debug("Using OR-Tools Basic drill path optimization.") + self.app.log.debug("Using OR-Tools Basic drill path optimization.") elif opt_type == 'T': - log.debug("Using Travelling Salesman drill path optimization.") + self.app.log.debug("Using Travelling Salesman drill path optimization.") elif opt_type == 'R': - log.debug("Using RTree path optimization.") + self.app.log.debug("Using RTree path optimization.") else: - log.debug("Using no path optimization.") + self.app.log.debug("Using no path optimization.") tool_dict = tools[tool]['data'] # check if it has drills if not points: - log.debug("Failed. No drills for tool: %s" % str(tool)) + self.app.log.debug("Failed. No drills for tool: %s" % str(tool)) return 'fail' if self.app.abort_flag: @@ -3377,7 +3379,7 @@ class CNCjob(Geometry): self.app.inform.emit('[ERROR] %s' % _("The End X,Y format has to be (x, y).")) return 'fail' except Exception as e: - log.error("camlib.CNCJob.tcl_gcode_from_excellon_by_tool() xy_end --> %s" % str(e)) + self.app.log.error("camlib.CNCJob.tcl_gcode_from_excellon_by_tool() xy_end --> %s" % str(e)) self.xy_end = [0, 0] # Probe parameters @@ -3478,7 +3480,7 @@ class CNCjob(Geometry): geo_len = len(optimized_path) old_disp_number = 0 - log.warning("Number of drills for which to generate GCode: %s" % str(geo_len)) + self.app.log.warning("Number of drills for which to generate GCode: %s" % str(geo_len)) loc_nr = 0 for point in optimized_path: @@ -3655,15 +3657,15 @@ class CNCjob(Geometry): opt_time = tool_dict['tools_mill_search_time'] if 'tools_mill_search_time' in tool_dict else 'R' if opt_type == 'M': - log.debug("Using OR-Tools Metaheuristic Guided Local Search path optimization.") + self.app.log.debug("Using OR-Tools Metaheuristic Guided Local Search path optimization.") elif opt_type == 'B': - log.debug("Using OR-Tools Basic path optimization.") + self.app.log.debug("Using OR-Tools Basic path optimization.") elif opt_type == 'T': - log.debug("Using Travelling Salesman path optimization.") + self.app.log.debug("Using Travelling Salesman path optimization.") elif opt_type == 'R': - log.debug("Using RTree path optimization.") + self.app.log.debug("Using RTree path optimization.") else: - log.debug("Using no path optimization.") + self.app.log.debug("Using no path optimization.") # Preprocessor self.pp_geometry_name = tool_dict['tools_mill_ppname_g'] @@ -3687,7 +3689,7 @@ class CNCjob(Geometry): flat_ext_geo, flat_ints_geo = self.flatten_exterior_interiors(geometry) flat_geometry = flat_ext_geo + flat_ints_geo # flat_geometry = self.flatten(geometry, reset=True, pathonly=True) - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) if tool_offset != 0.0: # for it in flat_geometry: @@ -3814,7 +3816,7 @@ class CNCjob(Geometry): self.app.inform.emit('[ERROR] %s' % _("The End X,Y format has to be (x, y).")) return 'fail' except Exception as e: - log.error("camlib.CNCJob.geometry_tool_gcode_gen xy_end --> %s" % str(e)) + self.app.log.error("camlib.CNCJob.geometry_tool_gcode_gen xy_end --> %s" % str(e)) self.xy_end = [0, 0] self.z_toolchange = tool_dict['tools_mill_toolchangez'] @@ -3834,7 +3836,7 @@ class CNCjob(Geometry): self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y format has to be (x, y).")) return 'fail' except Exception as e: - log.error("camlib.CNCJob.geometry_from_excellon_by_tool() --> %s" % str(e)) + self.app.log.error("camlib.CNCJob.geometry_from_excellon_by_tool() --> %s" % str(e)) pass self.extracut = tool_dict['tools_mill_extracut'] @@ -3890,7 +3892,7 @@ class CNCjob(Geometry): # Only if there are locations to mill if not optimized_path: - log.debug("camlib.CNCJob.geometry_tool_gcode_gen() -> Optimized path is empty.") + self.app.log.debug("camlib.CNCJob.geometry_tool_gcode_gen() -> Optimized path is empty.") return 'fail' if self.app.abort_flag: @@ -3902,7 +3904,7 @@ class CNCjob(Geometry): # ################# MILLING !!! ############################################################################## # ############################################################################################################# # ############################################################################################################# - log.debug("Starting G-Code...") + self.app.log.debug("Starting G-Code...") current_tooldia = float('%.*f' % (self.decimals, float(self.tooldia))) msg = '%s: %s%s.' % (_("Starting G-Code for tool with diameter"), str(current_tooldia), str(self.units)) @@ -3955,7 +3957,7 @@ class CNCjob(Geometry): # variables to display the percentage of work done geo_len = len(flat_geometry) - log.warning("Number of paths for which to generate GCode: %s" % str(geo_len)) + self.app.log.warning("Number of paths for which to generate GCode: %s" % str(geo_len)) old_disp_number = 0 current_pt = first_pt @@ -4006,7 +4008,7 @@ class CNCjob(Geometry): self.app.proc_container.update_view_text(' %d%%' % disp_number) old_disp_number = disp_number - log.debug("Finished G-Code... %s paths traced." % path_count) + self.app.log.debug("Finished G-Code... %s paths traced." % path_count) # add move to end position total_travel += abs(distance_euclidian(current_pt[0], current_pt[1], 0, 0)) @@ -4262,8 +4264,8 @@ class CNCjob(Geometry): has_drills = True break if not has_drills: - log.debug("camlib.CNCJob.tcl_gcode_from_excellon_by_tool() --> " - "The loaded Excellon file has no drills ...") + self.app.log.debug("camlib.CNCJob.tcl_gcode_from_excellon_by_tool() --> " + "The loaded Excellon file has no drills ...") self.app.inform.emit('[ERROR_NOTCL] %s...' % _('The loaded Excellon file has no drills')) return 'fail' @@ -4683,7 +4685,7 @@ class CNCjob(Geometry): geo_len = len(optimized_path) old_disp_number = 0 - log.warning("Number of drills for which to generate GCode: %s" % str(geo_len)) + self.app.log.warning("Number of drills for which to generate GCode: %s" % str(geo_len)) loc_nr = 0 for point in optimized_path: @@ -4795,15 +4797,17 @@ class CNCjob(Geometry): self.tools[one_tool]['gcode'] += end_gcode if used_excellon_optimization_type == 'M': - log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % str(measured_distance)) + self.app.log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % str(measured_distance)) elif used_excellon_optimization_type == 'B': - log.debug("The total travel distance with OR-TOOLS Basic Algorithm is: %s" % str(measured_distance)) + self.app.log.debug( + "The total travel distance with OR-TOOLS Basic Algorithm is: %s" % str(measured_distance)) elif used_excellon_optimization_type == 'T': - log.debug("The total travel distance with Travelling Salesman Algorithm is: %s" % str(measured_distance)) + self.app.log.debug( + "The total travel distance with Travelling Salesman Algorithm is: %s" % str(measured_distance)) elif used_excellon_optimization_type == 'R': - log.debug("The total travel distance with Rtree Algorithm is: %s" % str(measured_distance)) + self.app.log.debug("The total travel distance with Rtree Algorithm is: %s" % str(measured_distance)) else: - log.debug("The total travel distance with with no optimization is: %s" % str(measured_distance)) + self.app.log.debug("The total travel distance with with no optimization is: %s" % str(measured_distance)) # if used_excellon_optimization_type == 'M': # log.debug("Using OR-Tools Metaheuristic Guided Local Search drill path optimization.") @@ -5495,7 +5499,7 @@ class CNCjob(Geometry): :return: GCode - string """ - log.debug("generate_from_multitool_geometry()") + self.app.log.debug("generate_from_multitool_geometry()") temp_solid_geometry = [] if offset != 0.0: @@ -5511,7 +5515,7 @@ class CNCjob(Geometry): # ## Flatten the geometry. Only linear elements (no polygons) remain. flat_geometry = self.flatten(temp_solid_geometry, pathonly=True) - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) try: self.tooldia = float(tooldia) @@ -5568,7 +5572,7 @@ class CNCjob(Geometry): "but now there is only one value, not two.")) return 'fail' except Exception as e: - log.error("camlib.CNCJob.generate_from_multitool_geometry() --> %s" % str(e)) + self.app.log.error("camlib.CNCJob.generate_from_multitool_geometry() --> %s" % str(e)) pass self.pp_geometry_name = pp_geometry_name if pp_geometry_name else 'default' @@ -5629,7 +5633,7 @@ class CNCjob(Geometry): storage.get_points = get_pts # Store the geometry - log.debug("Indexing geometry before generating G-Code...") + self.app.log.debug("Indexing geometry before generating G-Code...") self.app.inform.emit(_("Indexing geometry before generating G-Code...")) for geo_shape in flat_geometry: @@ -5690,7 +5694,7 @@ class CNCjob(Geometry): total_cut = 0.0 # ## Iterate over geometry paths getting the nearest each time. - log.debug("Starting G-Code...") + self.app.log.debug("Starting G-Code...") self.app.inform.emit('%s...' % _("Starting G-Code")) path_count = 0 @@ -5700,7 +5704,7 @@ class CNCjob(Geometry): geo_len = len(flat_geometry) old_disp_number = 0 - log.warning("Number of paths for which to generate GCode: %s" % str(geo_len)) + self.app.log.warning("Number of paths for which to generate GCode: %s" % str(geo_len)) current_tooldia = float('%.*f' % (self.decimals, float(self.tooldia))) @@ -5765,7 +5769,7 @@ class CNCjob(Geometry): except StopIteration: # Nothing found in storage. pass - log.debug("Finished G-Code... %s paths traced." % path_count) + self.app.log.debug("Finished G-Code... %s paths traced." % path_count) # add move to end position total_travel += abs(distance_euclidian(current_pt[0], current_pt[1], 0, 0)) @@ -5869,7 +5873,7 @@ class CNCjob(Geometry): # flat_geometry = self.flatten(temp_solid_geometry, pathonly=True) flat_ext_geo, flat_ints_geo = self.flatten_exterior_interiors(geo_obj.solid_geometry) flat_geometry = flat_ext_geo + flat_ints_geo - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) # Create the solid geometry which will be used to generate GCode temp_solid_geometry = [] @@ -5990,7 +5994,7 @@ class CNCjob(Geometry): self.app.inform.emit('[ERROR] %s' % _("The Toolchange X,Y format has to be (x, y).")) return 'fail' except Exception as e: - log.error("camlib.CNCJob.generate_from_geometry_2() --> %s" % str(e)) + self.app.log.error("camlib.CNCJob.generate_from_geometry_2() --> %s" % str(e)) pass self.pp_geometry_name = pp_geometry_name if pp_geometry_name else 'default' @@ -6207,7 +6211,7 @@ class CNCjob(Geometry): except StopIteration: # Nothing found in storage. pass - log.debug("Finishing G-Code... %s paths traced." % path_count) + self.app.log.debug("Finishing G-Code... %s paths traced." % path_count) # add move to end position total_travel += abs(distance_euclidian(current_pt[0], current_pt[1], 0, 0)) @@ -6238,7 +6242,7 @@ class CNCjob(Geometry): :return: Gcode string """ - log.debug("Generate_from_solderpaste_geometry()") + self.app.log.debug("Generate_from_solderpaste_geometry()") # ## Index first and last points in paths # What points to index. @@ -6248,7 +6252,7 @@ class CNCjob(Geometry): self.gcode = "" if not kwargs: - log.debug("camlib.generate_from_solderpaste_geo() --> No tool in the solderpaste geometry.") + self.app.log.debug("camlib.generate_from_solderpaste_geo() --> No tool in the solderpaste geometry.") self.app.inform.emit('[ERROR_NOTCL] %s' % _("There is no tool data in the SolderPaste geometry.")) @@ -6278,14 +6282,14 @@ class CNCjob(Geometry): # ## Flatten the geometry. Only linear elements (no polygons) remain. flat_geometry = self.flatten(kwargs['solid_geometry'], pathonly=True) - log.debug("%d paths" % len(flat_geometry)) + self.app.log.debug("%d paths" % len(flat_geometry)) # Create the indexed storage. storage = FlatCAMRTreeStorage() storage.get_points = get_pts # Store the geometry - log.debug("Indexing geometry before generating G-Code...") + self.app.log.debug("Indexing geometry before generating G-Code...") for geo_shape in flat_geometry: if self.app.abort_flag: # graceful abort requested by the user @@ -6300,7 +6304,7 @@ class CNCjob(Geometry): self.gcode += self.doformat(p.toolchange_code) # ## Iterate over geometry paths getting the nearest each time. - log.debug("Starting SolderPaste G-Code...") + self.app.log.debug("Starting SolderPaste G-Code...") path_count = 0 current_pt = (0, 0) @@ -6338,7 +6342,7 @@ class CNCjob(Geometry): except StopIteration: # Nothing found in storage. pass - log.debug("Finishing SolderPste G-Code... %s paths traced." % path_count) + self.app.log.debug("Finishing SolderPste G-Code... %s paths traced." % path_count) self.app.inform.emit( '%s... %s %s.' % (_("Finished SolderPaste G-Code generation"), str(path_count), _("paths traced")) ) @@ -6452,7 +6456,7 @@ class CNCjob(Geometry): elif type(geometry) == Point: gcode_single_pass = self.point2gcode(geometry, cdia, z_move=z_move, old_point=old_point) else: - log.warning("G-code generation not implemented for %s" % (str(type(geometry)))) + self.app.log.warning("G-code generation not implemented for %s" % (str(type(geometry)))) return return gcode_single_pass @@ -6521,7 +6525,7 @@ class CNCjob(Geometry): gcode_multi_pass += self.point2gcode(geometry, cdia, z_move=z_move, old_point=old_point) break # Ignoring ... else: - log.warning("G-code generation not implemented for %s" % (str(type(geometry)))) + self.app.log.warning("G-code generation not implemented for %s" % (str(type(geometry)))) # Reverse coordinates if not a loop so we can continue cutting without returning to the beginning. if type(geometry) == LineString: @@ -6720,8 +6724,8 @@ class CNCjob(Geometry): if self.pp_geometry_name == 'Line_xyz' or self.pp_excellon_name == 'Line_xyz': pass else: - log.warning("Non-orthogonal motion: From %s" % str(current)) - log.warning(" To: %s" % str(gobj)) + self.app.log.warning("Non-orthogonal motion: From %s" % str(current)) + self.app.log.warning(" To: %s" % str(gobj)) current['Z'] = gobj['Z'] # Store the path into geometry and reset path @@ -6892,8 +6896,8 @@ class CNCjob(Geometry): if self.pp_geometry_name == 'Line_xyz' or self.pp_excellon_name == 'Line_xyz': pass else: - log.warning("Non-orthogonal motion: From %s" % str(current)) - log.warning(" To: %s" % str(gobj)) + self.app.log.warning("Non-orthogonal motion: From %s" % str(current)) + self.app.log.warning(" To: %s" % str(gobj)) current['Z'] = gobj['Z'] # Store the path into geometry and reset path @@ -7169,7 +7173,7 @@ class CNCjob(Geometry): font_size=self.app.defaults["cncjob_annotation_fontsize"], color=new_color) except Exception as e: - log.error("CNCJob.plot2() --> annotations --> %s" % str(e)) + self.app.log.error("CNCJob.plot2() --> annotations --> %s" % str(e)) if self.app.use_3d_engine: obj.annotation.clear(update=True) @@ -7877,9 +7881,9 @@ class CNCjob(Geometry): return obj.bounds if self.multitool is False: - log.debug("CNCJob->bounds()") + self.app.log.debug("CNCJob->bounds()") if self.solid_geometry is None: - log.debug("solid_geometry is None") + self.app.log.debug("solid_geometry is None") return 0, 0, 0, 0 bounds_coords = bounds_rec(self.solid_geometry) @@ -7953,7 +7957,7 @@ class CNCjob(Geometry): :return: None :rtype: None """ - log.debug("camlib.CNCJob.scale()") + self.app.log.debug("camlib.CNCJob.scale()") if yfactor is None: yfactor = xfactor @@ -8139,7 +8143,7 @@ class CNCjob(Geometry): :type vect: tuple :return: None """ - log.debug("camlib.CNCJob.offset()") + self.app.log.debug("camlib.CNCJob.offset()") dx, dy = vect @@ -8244,7 +8248,7 @@ class CNCjob(Geometry): :param point: tuple of coordinates (x,y). Point of origin for Mirror :return: """ - log.debug("camlib.CNCJob.mirror()") + self.app.log.debug("camlib.CNCJob.mirror()") px, py = point xscale, yscale = {"X": (1.0, -1.0), "Y": (-1.0, 1.0)}[axis] @@ -8288,7 +8292,7 @@ class CNCjob(Geometry): See shapely manual for more information: http://toblerity.org/shapely/manual.html#affine-transformations """ - log.debug("camlib.CNCJob.skew()") + self.app.log.debug("camlib.CNCJob.skew()") px, py = point @@ -8324,7 +8328,7 @@ class CNCjob(Geometry): :param point: tuple of coordinates (x,y). Origin point for Rotation :return: """ - log.debug("camlib.CNCJob.rotate()") + self.app.log.debug("camlib.CNCJob.rotate()") px, py = point @@ -8393,7 +8397,8 @@ def get_bounds(geometry_list): xmax = max([xmax, gxmax]) ymax = max([ymax, gymax]) except Exception: - log.warning("DEVELOPMENT: Tried to get bounds of empty geometry.") + # log.warning("DEVELOPMENT: Tried to get bounds of empty geometry.") + pass return [xmin, ymin, xmax, ymax] @@ -8868,7 +8873,7 @@ def three_point_circle(p1, p2, p3): try: T = solve(np.transpose(np.array([-b1, b2])), a1 - a2) except Exception as e: - log.error("camlib.three_point_circle() --> %s" % str(e)) + # log.error("camlib.three_point_circle() --> %s" % str(e)) return # Center diff --git a/tclCommands/TclCommandBounds.py b/tclCommands/TclCommandBounds.py index 1d2e94a7..dfe506bd 100644 --- a/tclCommands/TclCommandBounds.py +++ b/tclCommands/TclCommandBounds.py @@ -60,7 +60,7 @@ class TclCommandBounds(TclCommand): try: obj_list = [str(obj_name) for obj_name in str(args['objects']).split(",") if obj_name != ''] except AttributeError as e: - log.debug("TclCommandBounds.execute --> %s" % str(e)) + self.app.log.debug("TclCommandBounds.execute --> %s" % str(e)) if not obj_list: self.raise_tcl_error('%s: %s:' % ( diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 71aa9d55..c2c572ae 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -93,7 +93,7 @@ class TclCommandCopperClear(TclCommand): try: obj = self.app.collection.get_by_name(str(name)) except Exception as e: - log.error("TclCommandCopperClear.execute() --> %s" % str(e)) + self.app.log.error("TclCommandCopperClear.execute() --> %s" % str(e)) self.raise_tcl_error("%s: %s" % (_("Could not retrieve object"), name)) return "Could not retrieve object: %s" % name diff --git a/tclCommands/TclCommandGeoCutout.py b/tclCommands/TclCommandGeoCutout.py index 3296df36..fab7df21 100644 --- a/tclCommands/TclCommandGeoCutout.py +++ b/tclCommands/TclCommandGeoCutout.py @@ -137,7 +137,7 @@ class TclCommandGeoCutout(TclCommandSignaled): if type(target) == LineString or type(target) == LinearRing: diffs.append(target.difference(toolgeo)) else: - log.warning("Not implemented.") + self.app.log.warning("Not implemented.") return unary_union(diffs) if 'name' in args: diff --git a/tclCommands/TclCommandSetOrigin.py b/tclCommands/TclCommandSetOrigin.py index d721b3e2..2de8a553 100644 --- a/tclCommands/TclCommandSetOrigin.py +++ b/tclCommands/TclCommandSetOrigin.py @@ -87,7 +87,7 @@ class TclCommandSetOrigin(TclCommand): try: location = [float(eval(coord)) for coord in str(args['loc']).split(",") if coord != ''] except AttributeError as e: - log.debug("TclCommandSetOrigin.execute --> %s" % str(e)) + self.app.log.debug("TclCommandSetOrigin.execute --> %s" % str(e)) location = (0, 0) if len(location) != 2: