Forum

Author Topic: A way to force non-read-only open?  (Read 1772 times)

awilson

  • Newbie
  • *
  • Posts: 18
    • View Profile
A way to force non-read-only open?
« on: June 29, 2017, 08:19:15 PM »
I'm having a problem where a process will occasionally crash while I'm running it. When I try to re-run it, I run document.open( filename ), but it will only open read-only because it thinks the file is still in use. Is there any way to force it to open editable, or to switch a read-only document to editable after opening, via the API?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 10167
    • View Profile
Re: A way to force non-read-only open?
« Reply #1 on: June 30, 2017, 07:13:57 PM »
Hello awilson,

Do you mean the situations when the script is loading the locked project?

If you are working with the fully automated scripts, you can load the project to new PhotoScan.Document() class variable instead of PhotoScan.app.document that is related to the active document opened in GUI.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

awilson

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: A way to force non-read-only open?
« Reply #2 on: June 30, 2017, 08:56:05 PM »
That seems to be running into the same issue. The file is locked, but I want to open it and be able to make changes to it. I tried this code after your last comment:

Code: [Select]
import PhotoScan

newDoc = PhotoScan.Document()
newDoc.open('/tmp/my_locked_file.psx')

PhotoScan.app.quit()

And I see:
Document.open(): The document is opened in read-only mode because it is already in use.

Essentially, I want a way to do whatever happens when the GUI asks "Are you sure you want to edit this file?" and I say yes.

awilson

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: A way to force non-read-only open?
« Reply #3 on: July 03, 2017, 08:28:54 PM »
It looks like I can do this to get it to run:

Code: [Select]
if os.path.exists( '/tmp/my_locked_file.files/lock' ):
  os.remove( '/tmp/my_locked_file.files/lock' )
doc.open( '/tmp/my_locked_file.psx' )

Is that safe, as long as I'm sure the lock is accidental? Am I setting myself up for some sort of trouble down the line by just removing that file?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 10167
    • View Profile
Re: A way to force non-read-only open?
« Reply #4 on: July 03, 2017, 08:32:21 PM »
Hello awilson,

I think we will extend the API and will add the method/function to PhotoScan.Document() class variables, that would allow to remove the lock that can be removed - i.e. lock that is no longer used.
Best regards,
Alexey Pasumansky,
AgiSoft LLC

awilson

  • Newbie
  • *
  • Posts: 18
    • View Profile
Re: A way to force non-read-only open?
« Reply #5 on: July 03, 2017, 09:53:07 PM »
Awesome, thanks!