Forum

Author Topic: update console log while processing  (Read 3479 times)

ikemarv

  • Newbie
  • *
  • Posts: 7
    • View Profile
update console log while processing
« on: July 01, 2024, 01:15:30 PM »
Hi guys,

we want to give our users feedback about a progress of a copy job. The pogress should be visible on the console with the help of a print()- progress bar. Our problem is, that the output is not visible during the copy-process. Instead all logs appears at once, when the job is finished.
We have tried to refresh the console before a print()-method like it's mentioned in this post:  https://www.agisoft.com/forum/index.php?topic=9586.0

Code: [Select]
def start_alignment_process():
app = QtWidgets.QApplication.instance()
input_dir = Metashape.app.getExistingDirectory(
        "Path:")
       
        image_copier = ImageCopier(input_dir, PV_DIR, app)
        output_process = threading.Thread(
        target=image_copier.copy_directory_with_progress, args=())
output_process.start()

output_process.join()

class ImageCopier():
....
def copy_directory_with_progress(self) -> str:
self.app.processEvents()
print("Copy job started")
self.copytree_with_progress(self.src, self.dst)
# Wait for the copy thread to complete
self.app.processEvents()
print("Finished copy job.")
print()  # Move to the next line after completion
return self.dst

Unfortunately, it didn't help. Do you have any suggestions for us?

Kind regards,
Eike Sippel


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15418
    • View Profile
Re: update console log while processing
« Reply #1 on: July 02, 2024, 12:25:37 PM »
Hello Eike,

Does it help if you put app.processEvents() after print() lines instead of having them in front of printing lines?

Also I would rather suggest to initialize app as:
Code: [Select]
global app
app = QtWidgets.QApplication.instance()

And then just call app instead of self.app - you can try that, if the first approach does not work.
Best regards,
Alexey Pasumansky,
Agisoft LLC