Close

Command Action problems and solution!

Having trouble with Sighthound Video? Post here for help.

Moderator: Staff

no avatar
dylanparker
 
Posts: 4
Joined: Wed Feb 06, 2013 4:30 pm

Command Action problems and solution!

by dylanparker » Wed Feb 06, 2013 6:04 pm

I banged my head on this for a while before solving it, so thought I'd post here to help others.

Problem:
I had a simple python script that makes a HTTP POST request that triggers a Prowl notification on my iPhone.
If I ran the script from the command line, it worked fine. I received the notification.
If I instead added it to the Vitamin D "Run a Command" action field and clicked 'Test' -- nothing happened.

I won't bore you with my many (many) attempts to figure out what was going on...

Reason for Problem:
When the script was triggered by Vitamin D, the PYTHONPATH and PYTHONHOME environment variables were being set to:
PYTHONHOME="/Applications/Vitamin D Video.app/Contents/Resources"
PYTHONPATH="/Applications/Vitamin D Video.app/Contents/Resources"
This means Python was unable to import the appropriate libraries.

The Fix:
The fix is to add a "-E" to the hashbang line in your script.
#!/usr/bin/python -E
This tells Python to ignore the environment variables and just use its defaults.

It isn't clear to me why those env vars are being set that way... if it is something that VitaminD is doing, perhaps they can stop.
Hope this saves someone else some head scratching.

User avatar
ryan
 
Posts: 1015
Joined: Wed Aug 25, 2010 2:52 pm
Location: Palo Alto, California

Re: Command Action problems and solution!

by ryan » Thu Feb 07, 2013 6:02 pm

Hi dylan,

Sorry for the trouble. It is being executed that way because, believe it or not, VDV is mostly written in python. To ensure that it runs consistently across machines (which might not have python installed, or which might have an incompatible version) it includes it's own python runtime. When your script is being executed it is being run from inside an environment that is using that custom python runtime and so it picks that up as the default.

Glad you figured your problem out, thanks for posting for others!
- ryan


Return to Technical Support