Add environment information when calling Python scripts

Posted on
Thu Jul 11, 2019 4:13 am
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Add environment information when calling Python scripts

For Python scripts called with Execute Script (Script and File Actions) would it be possible to provide contextual information about the environment when executing the script (internal and external)?

At the present time it appears there is only one environment variable passed to the script: __CF_USER_TEXT_ENCODING
It would be really nice if a script could know how it was called, like the name or ID number of the Trigger, Action Group or Schedule that executed the script.

The environment could then be access using:
import os
foo = os.environ['FOO']

Thanks.

Posted on
Thu Jul 11, 2019 8:28 am
jay (support) offline
Site Admin
User avatar
Posts: 15519
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Add environment information when calling Python scripts

As we've discussed before, there currently is no connection (in terms of data flow) in the server between the triggering event and the action, so it would require non-trivial amount of server work to address. It's on our todo list, but has never gotten high enough in priority to address. We do want to do it someday.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jul 11, 2019 11:16 am
FlyingDiver offline
Posts: 3185
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Add environment information when calling Python scripts

Jay - just for my nerd curiosity.

Sounds like what's happening in the server is that when an action gets triggered (however that happens), a reference to the action to be performed is added to an execution queue. And when the queue consumer gets to that item, the only thing available is the reference to the action. So to actually change that, the information put into the queue would need to be expanded. Am I close?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Jul 11, 2019 1:26 pm
jay (support) offline
Site Admin
User avatar
Posts: 15519
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Add environment information when calling Python scripts

FlyingDiver wrote:
Am I close?


That's part of the issue (basically, it's an Action object which currently doesn't know anything about how it was configured or from where it was fired).

But the other thing is that if we are going to do this, we're going to do it the right way, which is to pass that data to all actions (not just scripts). Which means that we have to retrofit any action config UIs (where it makes sense) to use any of that data, including the script execution actions, and that's Mac Client work (which is completely different than server work). It's unlikely we'd use an environmental variable for a variety of reasons (though without completing the design I don't know for sure), but probably rather passing the actual IOM object(s) to the script somehow which will also likely be needed when we implement Python script conditions as well. Also, we really need to complete the Trigger and Schedule IOMs so that everything about them can be referenced (including other actions, delays, etc., which might be useful particularly to scripts).

So, bottom line, I don't think either of us wants to implement a solution that's not a full and well thought out solution, and there are other things that need to be done in a specific order which will make the final implementation become more obvious when we come to it.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests