-
Notifications
You must be signed in to change notification settings - Fork 4
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
Problem running script in Devonthink #11
Comments
When AppleScript executes an external shell command, it does not respect any shell In a recent update to the DEVONthink AppleScript code, I tried to work around this problem by explicitly setting Here are some possible things to try:
|
Thanks so much for getting back to me. I used the 'this version' script and tried and still got the same error. I ran the 'which python3' command and this was the output: /Users/jeffkiefer/miniconda3/bin/python3 |
Close: remove "python3" -- the path needs to be to a directory, like this:
Also, it may be a good idea to check that |
I moved the zowie 3.9 downloaded file to this location ~/miniconda3/bin/zowie. At the command line I type zowie -h I get the help pages.
This is the code for the ‘run zowie’ rule:
…-- ======================================================================
-- @file Run Zowie on newly indexed PDF.applescript
-- @brief Script for DEVONthink smart rule to run Zowie on new additions
-- @author Michael Hucka ***@***.***>
-- @license MIT license; please see the file LICENSE in the repo
-- @repo https://github.com/mhucka/devonthink-hacks
--
-- This is an AppleScript fragment that will only work as the script
-- executed by a Smart Rule in DEVONthink. For more information, see
-- https://github.com/mhucka/devonthink-hacks/zowie-scripts
-- ======================================================================
on performSmartRule(selectedRecords)
tell application "System Events"
-- In my environment, Zotero takes time to upload a newly-added
-- PDF to the cloud. The following delay is needed to give time
-- for the upload to take place, so that when Zowie runs and
-- queries Zotero via the network API, the data will be there.
delay 15
end tell
tell application id "DNtp"
try
repeat with _record in selectedRecords
set raw_path to the path of _record
-- A problem for shell strings is embedded single quotes.
-- Combo of changing text delimiters & using AppleScript
-- "quoted form of" seems to do the trick.
set AppleScript's text item delimiters to "\\\\"
set quoted_file_path to quoted form of raw_path
-- Now run Zowie. The PATH setting adds common locations
-- where Zowie may be installed on the user's computer.
set result to do shell script ¬
¬
"PATH=$PATH:$HOME/miniconda3/bin" & " zowie -s -q " & quoted_file_path
-- Display a notification if Zowie returned a msg.
if result ≠ "" then
display notification result
else
-- If all went well, tell DEVONthink explicitly to set
-- the comment, because it does not consistently
-- "notice" the addition of a comment after a file has
-- already been indexed.
set comment of _record to my finderComment(raw_path)
-- Also force execution of smart rules with "on import"
-- triggers. This is needed because some of my rules use
-- the URL in the Finder comment, but DEVONthink smart
-- rules won't trigger when the only change to a file is
-- to the Finder comment.
perform smart rule record _record trigger import event
end if
end repeat
on error msg number code
if the code is not -128 then
display alert "DEVONthink" message msg as warning
end if
end try
end tell
end performSmartRule
-- Function to ask the Finder to read the comment.
on finderComment(f)
tell application "Finder"
return comment of (POSIX file f as alias)
end tell
end finderComment
-- Function to make literal text substitutions.
-- The following function is based on code posted by user "mb21" on
-- 2016-06-26 at https://stackoverflow.com/a/38042023/743730
on substituted(search_string, replacement_string, this_text)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end substituted
—
This is the cod from the ’set URL from Finder Comment:
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
set URL of theRecord to (get comment of theRecord)
end repeat
end tell
end performSmartRule
——
Thanks again for your assitance.
Jeff
On Feb 9, 2022, at 1:35 PM, Mike Hucka ***@***.***> wrote:
Close: remove "python3" -- the path needs to be to a directory, like this:
"PATH=$PATH:$HOME/miniconda3/bin" & " zowie -s -q " & quoted_path
Also, it may be a good idea to check that zowie exists in /Users/jeffkiefer/miniconda3/bin/, i.e., check for the existence of /Users/jeffkiefer/miniconda3/bin/zowie. If you installed it via pip, it should have ended up there, but you never know ...
—
Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEF5456YZN6N6Z6TFUS7BTTU2LF2LANCNFSM5NTC7LBQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
|
I'm not sure if there was a question in your last reply. Is it working now? |
Oh, I am sorry. It working, it is throwing the wrong version of python.
JK
… On Feb 9, 2022, at 2:23 PM, Mike Hucka ***@***.***> wrote:
I'm not sure if there was a question in your last reply.
Is it working now?
—
Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEF5453P6WRTUAWVEJ5EOKLU2LLONANCNFSM5NTC7LBQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
|
Sorry about this, but your last sentence contains contradictory statements: "it working" but also "wrong version of python", and I can't figure out what that means. Can you clarify? |
I can invoke the zowie help page in the terminal, when zowie is in the anaconda3/bin folder.
The run zowie Devonthink rule still throws the wrong python error. I cut and pasted the code from both devonthink rules in the longer email. So the devonthink smart rules are still not working.
Jeff
… On Feb 9, 2022, at 2:27 PM, Mike Hucka ***@***.***> wrote:
Sorry about this, but your last sentence contains contradictory statements: "it working" but also "wrong version of python", and I can't figure out what that means. Can you clarify?
—
Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEF5453JOMFFXTNLHNXO5IDU2LL3HANCNFSM5NTC7LBQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
|
This is a weird error. How did you install Zowie? Edit: I know you wrote "I have downloaded ZOWIE from your site", but which version of Zowie? Prebuilt-binary (and if so, which one) or via pip, or something else? |
Hi Mike,
I installed via instructions for manual download and place in folder specified. I am out of town till Wed, I will check back then.
Jeff
… On Feb 9, 2022, at 11:25 PM, Mike Hucka ***@***.***> wrote:
How did you install Zowie in the first place?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you authored the thread.
|
I'm not sure what "manual download" means. Can you please look at the installation section at https://github.com/mhucka/zowie/#installation and tell me exactly which one of the 4 listed approaches you followed? It matters to deducing what's going on. |
Hi Mike,
Sorry for getting back to you late, I was out of office for last week. The initial set-up was Alternative 1 macOS 10.15 (Catalina) and later.
Jeff
… On Feb 14, 2022, at 5:54 PM, Mike Hucka ***@***.***> wrote:
I'm not sure what "manual download" means. Can you please look at the installation section at https://github.com/mhucka/zowie/#installation <https://github.com/mhucka/zowie/#installation> and tell me exactly which one of the 4 listed approaches you followed? It matters to deducing what's going on.
—
Reply to this email directly, view it on GitHub <#11 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEF545YFZKKMORXOU2I244TU3GP4RANCNFSM5NTC7LBQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.
|
I have downloaded ZOWIE from your site and installed it and works fine running from the command line. I am using python 3.9. I also have implanted the Devonthink rules that you list. The 'Run Zowie on newly indexed PDF.applescript' scrript, throws an error within Devonthink saying that I have python 3.8. Don't understand why it runs at command line but not in the script. Possible has something to do with the path, but not sure. Any thoughts? Thanks in advance for your help.
The text was updated successfully, but these errors were encountered: