Forum

Author Topic: Disabling read-only lock when quitting Metashape?  (Read 18904 times)

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Disabling read-only lock when quitting Metashape?
« on: March 24, 2024, 10:18:43 PM »
Hello,

Is it possible to prevent a read-only lock on a project when closing Metashape using Metashape.app.quit()? I always receive a pop-up when opening a project using the GUI following processing using a script.

Thanks!

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15600
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #1 on: March 25, 2024, 07:53:35 PM »
Hello Wizyza,

What Metashape version and what OS version you are using?
Best regards,
Alexey Pasumansky,
Agisoft LLC

jpaton

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #2 on: April 04, 2024, 11:45:15 AM »
I have the same issue, i am working on ubuntu 18 with metashape 1.8.4

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15600
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #3 on: April 04, 2024, 12:44:46 PM »
Hello jpaton,

Can you confirm, if you observe the same behavior in 2.1.1 version? Does it happen only when Metashape.app.quit() is used or the lock remains, when you exit the application by clicking on "X" mark in GUI's corner?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #4 on: April 10, 2024, 07:01:42 PM »
Hi Alexey,

Sorry, I didn't realize you responded.

Just in case I wasn't clear in my initial post, I wrote a script to handle my processing from the CLI. If I then open the project file in the GUI, I get the read-only mode message box. It seems that using Metashape.app.quit() at the end of my script does not properly close the project.

Closing the project through the GUI, by clicking on the 'X', does not produce this issue.

I am currently running version 2.1.1.17821 on Windows 11 23H2.

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #5 on: April 10, 2024, 09:58:12 PM »
Hi Alexey,

I also want to add that when I run my script from within the GUI and Metashape.app.quit() executes from within the GUI, terminating the application, when I reload the project, I do not get the message.

This seems to only happen when Metashape.app.quit() is executed through the CLI.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15600
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #6 on: April 12, 2024, 01:14:17 PM »
Hello Wizyza,

If your script is run from the command line, then it should automatically "unlock" Metashape project when the script is over. Or whether the script is working constantly and from time to time is accessing the projects?
And whether you apply any changes to the project and save it by the script?
Best regards,
Alexey Pasumansky,
Agisoft LLC

Wizyza

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #7 on: April 16, 2024, 10:04:09 PM »
Hi Alexey,

Do I need Metashape.app.quit() at the end of my script? I need it to stop the process, correct?

The message when I open the project in the GUI is just a minor nuisance, but I wish I knew why it was happening.

I assume that a workaround if I wanted to re-open the project via CLI is that I could pass the argument telling Metashape to ignore the lock status when opening the project.

Thank you again for your help.

Sylvain M.

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #8 on: July 18, 2024, 05:57:48 PM »
I'm taking my first steps with Metashape Python API, and I'm having the same problem with Locked Projects.
I've tried
Code: [Select]
Metashape.app.quit()or
Code: [Select]
os.remove(r"D:\PATH\PROJECT.files\lock")but nothing works: the project remains locked at the end of the execution of my Python scripts.

I see that the problem has been raised several times * over the years: are there any possible workarounds?

 * examples :
https://www.agisoft.com/forum/index.php?topic=16331
https://www.agisoft.com/forum/index.php?topic=9981
https://www.agisoft.com/forum/index.php?topic=12951.0
https://www.agisoft.com/forum/index.php?topic=13581

Sylvain M.

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #9 on: July 30, 2024, 01:50:48 PM »
Rather than deleting the lock file at the end of processing (which doesn't work at the moment because the lock file is locked by the current processing), I finally added the deletion of the previous lock file at the start of new processing.
This works because previous processing is usually finished when a new Python script is executed.
Code: [Select]
# Remove Lockfile (if exist)
lockfile = project_path.replace(".psx", ".files\\lock")

try:
    os.remove(lockfile)
    print(f"lockfile deleted")
except FileNotFoundError:
    print(f"no lockfile")
except PermissionError:
    print(f"Permission denied to delete lockfile")

It works for my needs ;)

Frédéric Devernay

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #10 on: November 21, 2024, 12:44:24 AM »
Code: [Select]
del docworks fine. It closes the file and removes the lock file. You can then reopen it read-only or read-write.

Sylvain M.

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: Disabling read-only lock when quitting Metashape?
« Reply #11 on: November 22, 2024, 08:22:27 PM »
Code: [Select]
del docworks fine. It closes the file and removes the lock file. You can then reopen it read-only or read-write.

Many thanks Frédéric!
It was so easy!!!
Tested and approved just now  8)
(Merci Beaucoup Frédéric, puisque je vois que tu es francophone !  ;) )