Issues running export script
Good morning!
So I think I need a sanity check from someone here. I'm working on a project that will involve taking hundreds of raw IIQ files, converting them to tif/jpeg, and running some additional steps. Obviously, I don't want to have to convert those images by hand, so I'm trying to figure out how to automate this.
After fighting with AppleScript for a while, I've got to a script that seems to mostly work, though I'm consistently running into an issue. The script is run from command line, like `osascript convert_image.scpt /path/to/image`. Although the file does save successfully, Capture One throws a few errors related to writing to the session's SQLite database:
The script in question:
I created a support ticket about this, and they quickly got back to me with a suggestion that it's probably related to the fact that I'm opening a new document ("My hunch is that the catalog database is mid-transaction and basically saying 'don't interrupt me, I'm working'. "). I think they're probably right. I've found that if I add a `delay` command after calling `make new document`, and another after setting the output paths, it does seem to work without error.
Does anyone have any advice for a more sane way to accomplish this? I'm not very confident in this script, and its ability to run without error.
So I think I need a sanity check from someone here. I'm working on a project that will involve taking hundreds of raw IIQ files, converting them to tif/jpeg, and running some additional steps. Obviously, I don't want to have to convert those images by hand, so I'm trying to figure out how to automate this.
After fighting with AppleScript for a while, I've got to a script that seems to mostly work, though I'm consistently running into an issue. The script is run from command line, like `osascript convert_image.scpt /path/to/image`. Although the file does save successfully, Capture One throws a few errors related to writing to the session's SQLite database:
com.phaseone.captureone.SQLite.ErrorDomain code 8 ObjectContext.m:2837] - SQLite Error 8 (1032) - attempt to write a readonly database (attempt to write a readonly database) : No message.
com.phaseone.captureone.SQLite.ErrorDomain code 1 ObjectContext.m:2837] - SQLite Error 1 (1) - cannot start a transaction within a transaction (cannot start a transaction within a transaction) : No message.
The script in question:
on run argv
if (count of argv) < 2 then
# just quit?
end if
set theFile to item 1 of argv # passing in the filepath as a command line argument
if application "Capture One 12" is not running then
tell application "Capture One 12" to activate
tell application "Capture One 12"
set newDoc to make new document with properties {kind:catalog, path:"some path"}
end tell
end if
tell application "Capture One 12"
set theDoc to current document
set output of theDoc to "another path"
set output sub path of theDoc to "processed"
tell theDoc
activate
process theFile recipe "JPEG sRGB"
end tell
end tell
end run
I created a support ticket about this, and they quickly got back to me with a suggestion that it's probably related to the fact that I'm opening a new document ("My hunch is that the catalog database is mid-transaction and basically saying 'don't interrupt me, I'm working'. "). I think they're probably right. I've found that if I add a `delay` command after calling `make new document`, and another after setting the output paths, it does seem to work without error.
Does anyone have any advice for a more sane way to accomplish this? I'm not very confident in this script, and its ability to run without error.
0
-
I've done a lot of Applescrips for Capture One, but I've not run into these particular errors, probabaly because my scripts assume that Capture On eis already open and running.
I've no comment on you way of starting your AppleScript, it seems complex but you probably do it that way because you're starting it from some other Application.
I would add this line to ensure Capture One is using the intended document
tell application "Capture One 12" to set current document to newDoc
Regarding the intermittent errors, I would put them inside a try loop, like this below. Fine tuning tryMax and the delay should result in stable operation with a minimum of delay.
set {trySuccess, tryMax, debug} to {false, 3, true} -- set debug to false after debugging finished
repeat with tryCtr from 1 to tryMax
try
## my problem line here
set trySuccess to true
exit repeat
on error errmess
if debug then tell me to log "Attempt " & tryCtr & " Error: " & (get errmess)
delay 0.3
end try
end repeat
if not trySuccess then error "Not successful after " & tryMax & " attempts"0 -
Essentially I was going to suggest the same as Eric's previous response, but the quick/dirty/one-time-use way: ...
if application "Capture One 12" is not running then
tell application "Capture One 12" to activate
repeat until isReady is true
try
tell application "Capture One 12"
set newDoc to make new document with properties {kind:catalog, path:"some path"}
end tell
set isReady to true
on error
set isReady to false
delay .1
end try
end repeat
end try
...
I haven't tested this yet, so probably go with Eric's suggestion 😊.0 -
I've been experimenting with your script and find several other issues.
The first is clearly a Capture One bug. if you try to create a catalog with {kind:catalog, path:somePath} and no name property, as you have done, Capture One creates a catalog with the name "UntitiledSession"
(Initially I thought that this was session, but that was not so, It is a catalog. I have cancelled Support Ticket #337761)
For now, if you want Capture to create a new catalog reliably, then you must supply a name.
Second, I observe that your script says that if Capture One is not running, then activate it and create a new document. (OK)
But if it is already running, do nothing, and then the current document is used. But here you don't know if there is even a Capture One current document, if there is, what kind is it, nor what is its name, history and contents. (IMO not so OK).
I would use a different approach:
Use one Capture One catalog, with a designated name, and known location, as the vehicle for this script.
Now you can easily check that it is open, does it exist, delete it, create it and so forth.
Within this special catalog, create a new Project for each run of the script. Perhaps the Project name includes the date and Time. Within the Project there must be one album as a minimum, call it "EveryImage" if you like.
This "EveryImage" album becomes the target collection for this Import. Now you can find your imported files, handy when you are processing them.
At the end of the script you can keep everything, or you can delete the Project, or you can delete these images from the catalog0 -
[quote="ben_US" wrote:
Essentially I was going to suggest the same as Eric's previous response, but the quick/dirty/one-time-use way:...
if application "Capture One 12" is not running then
tell application "Capture One 12" to activate
repeat until isReady is true
try
tell application "Capture One 12"
set newDoc to make new document with properties {kind:catalog, path:"some path"}
end tell
set isReady to true
on error
set isReady to false
delay .1
end try
end repeat
end try
...
I haven't tested this yet, so probably go with Eric's suggestion 😊.
The risk with this script is that if something unexpected goes wrong (e.g. typo), the repeat loop will cycle for ever, hang the script and likely Capture One as well.
I always include a limit so that I get an error message instead of a hang.
I can't count the number of times I've put a try statement in place, only to discover that my typo is causing the error. 😄
So, at least initially I log the error.0 -
[quote="Eric Nepean" wrote:
[quote="ben_US" wrote:
Essentially I was going to suggest the same as Eric's previous response, but the quick/dirty/one-time-use way:...
if application "Capture One 12" is not running then
tell application "Capture One 12" to activate
repeat until isReady is true
try
tell application "Capture One 12"
set newDoc to make new document with properties {kind:catalog, path:"some path"}
end tell
set isReady to true
on error
set isReady to false
delay .1
end try
end repeat
end try
...
I haven't tested this yet, so probably go with Eric's suggestion 😊.
The risk with this script is that if something unexpected goes wrong (e.g. typo), the repeat loop will cycle for ever, hang the script and likely Capture One as well.
I always include a limit so that I get an error message instead of a hang.
I can't count the number of times I've put a try statement in place, only to discover that my typo is causing the error. 😄
So, at least initially I log the error.
Good call 😊0
Post is closed for comments.
Comments
5 comments