Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging error in the QGIS-python console (print) #28

Closed
dieuska opened this issue Sep 9, 2024 · 5 comments
Closed

logging error in the QGIS-python console (print) #28

dieuska opened this issue Sep 9, 2024 · 5 comments
Assignees
Labels
bug Something isn't working fixed_with new_brdr_version help wanted Extra attention is needed
Milestone

Comments

@dieuska
Copy link
Collaborator

dieuska commented Sep 9, 2024

When executing brdrQ, a logging error is shown in the QGIS python print console:

--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init_.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 232, in executeAlgorithm
self.executeWithGui.emit(alg.id(), self, self.in_place_mode, False)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\ProcessingPlugin.py", line 435, in executeAlgorithm
dlg.exec()
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 332, in runAlgorithm
ok, results = execute(self.algorithm(), parameters, self.context, self.feedback)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 62, in execute
results, ok = alg.run(parameters, context, feedback)
File "C:\Users\KarelDieussaert\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\autocorrectborders.py", line 668, in processAlgorithm
aligner = Aligner(feedback=log_info,
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 158, in init
self.logger.feedback_info("Aligner initialized")
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\logger.py", line 22, in feedback_info
logging.info(text)
Message: 'Aligner initialized'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init_.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 232, in executeAlgorithm
self.executeWithGui.emit(alg.id(), self, self.in_place_mode, False)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\ProcessingPlugin.py", line 435, in executeAlgorithm
dlg.exec()
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 332, in runAlgorithm
ok, results = execute(self.algorithm(), parameters, self.context, self.feedback)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 62, in execute
results, ok = alg.run(parameters, context, feedback)
File "C:\Users\KarelDieussaert\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\autocorrectborders.py", line 705, in processAlgorithm
aligner.load_reference_data(
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 1054, in load_reference_data
) = loader.load_data()
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\grb.py", line 438, in load_data
self.aligner.logger.feedback_info(f"GRB downloaded: {self.grb_type}")
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\logger.py", line 22, in feedback_info
logging.info(text)
Message: 'GRB downloaded: GRBType.ADP'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init_.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 232, in executeAlgorithm
self.executeWithGui.emit(alg.id(), self, self.in_place_mode, False)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\ProcessingPlugin.py", line 435, in executeAlgorithm
dlg.exec()
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 332, in runAlgorithm
ok, results = execute(self.algorithm(), parameters, self.context, self.feedback)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 62, in execute
results, ok = alg.run(parameters, context, feedback)
File "C:\Users\KarelDieussaert\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\autocorrectborders.py", line 705, in processAlgorithm
aligner.load_reference_data(
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 1055, in load_reference_data
self.prepare_reference_data()
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 682, in prepare_reference_data
self.logger.feedback_info(
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\logger.py", line 22, in feedback_info
logging.info(text)
Message: 'length of reference_dict: 366'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init
.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 232, in executeAlgorithm
self.executeWithGui.emit(alg.id(), self, self.in_place_mode, False)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\ProcessingPlugin.py", line 435, in executeAlgorithm
dlg.exec()
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 332, in runAlgorithm
ok, results = execute(self.algorithm(), parameters, self.context, self.feedback)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 62, in execute
results, ok = alg.run(parameters, context, feedback)
File "C:\Users\KarelDieussaert\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\autocorrectborders.py", line 717, in processAlgorithm
process_result = aligner.process_dict_thematic(
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 301, in process_dict_thematic
self.logger.feedback_info("thematic id to process: " + str(key))
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\logger.py", line 22, in feedback_info
logging.info(text)
Message: 'thematic id to process: 100'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init
.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 232, in executeAlgorithm
self.executeWithGui.emit(alg.id(), self, self.in_place_mode, False)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\ProcessingPlugin.py", line 435, in executeAlgorithm
dlg.exec()
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 332, in runAlgorithm
ok, results = execute(self.algorithm(), parameters, self.context, self.feedback)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 62, in execute
results, ok = alg.run(parameters, context, feedback)
File "C:\Users\KarelDieussaert\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\autocorrectborders.py", line 717, in processAlgorithm
process_result = aligner.process_dict_thematic(
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 301, in process_dict_thematic
self.logger.feedback_info("thematic id to process: " + str(key))
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\logger.py", line 22, in feedback_info
logging.info(text)
Message: 'thematic id to process: 200'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init_.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'write'
Call stack:
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\ProcessingToolbox.py", line 232, in executeAlgorithm
self.executeWithGui.emit(alg.id(), self, self.in_place_mode, False)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\ProcessingPlugin.py", line 435, in executeAlgorithm
dlg.exec()
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmDialog.py", line 332, in runAlgorithm
ok, results = execute(self.algorithm(), parameters, self.context, self.feedback)
File "C:\PROGRA1/QGIS331.1/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 62, in execute
results, ok = alg.run(parameters, context, feedback)
File "C:\Users\KarelDieussaert\AppData\Roaming\QGIS\QGIS3\profiles\default\processing\scripts\autocorrectborders.py", line 717, in processAlgorithm
process_result = aligner.process_dict_thematic(
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\aligner.py", line 301, in process_dict_thematic
self.logger.feedback_info("thematic id to process: " + str(key))
File "C:\Users\KarelDieussaert\AppData\Roaming\Python\Python312\site-packages\brdr\logger.py", line 22, in feedback_info
logging.info(text)
Message: 'thematic id to process: 300'
Arguments: ()
--- Logging error ---
Traceback (most recent call last):
File "C:\PROGRA1\QGIS331.1\apps\Python312\Lib\logging_init_.py", line 1163, in emit
stream.write(msg + self.terminator)
^^^^^^^^^^^^

@dieuska dieuska added the bug Something isn't working label Sep 9, 2024
@dieuska dieuska added this to the 0.9.6 milestone Sep 9, 2024
@dieuska dieuska self-assigned this Sep 9, 2024
@dieuska
Copy link
Collaborator Author

dieuska commented Sep 10, 2024

When adding the QGIS feedback logger to the aligner, ther isn't a problem. When setting this to None this error occurs. To check if brdr handles this correctly when no QGIS-logger is provided.

@dieuska dieuska added the help wanted Extra attention is needed label Sep 10, 2024
@dieuska
Copy link
Collaborator Author

dieuska commented Sep 10, 2024

@roefem I have a question about this.
When using the aligner in QGIS, and we provide a QGIS-feedback-logger in the Aligner-initialisation, everything goes well.

I also made a advanced parameter in the UI to not include the feedback-logger. So None is provided on initialisation. this results in error in the printing module of QGIS, because logging cannot be written. You have an idea how to handle this in the most clean way? Or should we always provide a QGIS-feedback-logger? (I removed this because too much info was written down in the QGIS log so the feedback-logger could not follow writing and was slowing the processing)

@dieuska
Copy link
Collaborator Author

dieuska commented Sep 10, 2024

zie:

brdrQ/autocorrectborders.py

Lines 684 to 691 in 5fd46d8

if self.SHOW_LOG_INFO:
log_info = feedback
else:
log_info = None
aligner = Aligner(feedback=log_info,
relevant_distance=self.RELEVANT_DISTANCE,
threshold_overlap_percentage=self.THRESHOLD_OVERLAP_PERCENTAGE,
)

@dieuska
Copy link
Collaborator Author

dieuska commented Sep 10, 2024

fix was needed in brdr. This fix will be available from version >=0.2.2

@dieuska dieuska added the new_brdr_version_needed for this feature a new version of brdr is needed label Sep 10, 2024
@dieuska dieuska modified the milestones: 0.9.6, future, 0.9.7 Sep 10, 2024
@dieuska
Copy link
Collaborator Author

dieuska commented Sep 11, 2024

we close this here as this is already fixed in brdr

@dieuska dieuska closed this as completed Sep 11, 2024
@dieuska dieuska added fixed_with new_brdr_version and removed new_brdr_version_needed for this feature a new version of brdr is needed labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed_with new_brdr_version help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant