Reload Libraries and Attachments

Posted on
Wed Jun 19, 2019 9:33 am
Mark offline
User avatar
Posts: 126
Joined: Apr 21, 2005
Location: California

Reload Libraries and Attachments

I was successful (thanks to the excellent example documentation!) in creating a python attachment and making calls to it. It's in the "/Library/Python/2.7/site-packages/" folder. Two questions:

1.
Is that where is must reside? I'd prefer to keep it in Indigo's folder, as I did with AppleScript attachments.

2.
When I edit the code, and select the "Reload Libraries and Attachments" menu item (either from the server's computer or the client computer), the new code does not take affect. I have to actually restart the Indigo server, which, as you can imagine, really slows down development. Am I doing something wrong? Or does that documentation online needed to be corrected?

Posted on
Wed Jun 19, 2019 9:55 am
jay (support) offline
Site Admin
User avatar
Posts: 15693
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload Libraries and Attachments

1) Starting with Indigo 7.3, you can now store them here:

/Library/Application Support/Perceptive Automation/Indigo 7/Scripts/Attachments/

and they will be available from Indigo Python scripts and plugins.

2) What version of Indigo are you using, and where are you running the script from?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 19, 2019 10:05 am
Mark offline
User avatar
Posts: 126
Joined: Apr 21, 2005
Location: California

Re: Reload Libraries and Attachments

Still running 7.2.

The script is here:
/Library/Python/2.7/site-packages/

Yay to keeping it in the Indigo 7/Scripts/Attachments folder.

Will upgrading to 7.3 and placing it there solve for the Reloading issue I'm having?

Posted on
Wed Jun 19, 2019 10:36 am
matt (support) offline
Site Admin
User avatar
Posts: 19334
Joined: Jan 27, 2003
Location: Texas

Re: Reload Libraries and Attachments

Yes, it should.

Image

Posted on
Wed Jun 19, 2019 10:37 am
Mark offline
User avatar
Posts: 126
Joined: Apr 21, 2005
Location: California

Re: Reload Libraries and Attachments

I've updated to 7.3.1.

OK!

The script runs while placed in the Attachments folder. Yay! Thanks for that. And Indigo successfully reloaded the script after using the "Reload Libraries and Attachments" menu item. So that's excellent.

But...

This is the log entry:

Stopping embedded script executor host (pid 4894)
Stopped "embedded script executor host"
Loading attachments
"update logs.scpt" script loaded


Note that the while the log indicates that one of my AppleScripts got reloaded, it doesn't list the Python script as reloaded (even though it did, in fact, reload).

And...

There's now a mystery file, with the same name as my Python attachment script, with suffix "pyc". I didn't create that. Just curious about it. I'm assuming I should leave that alone. Unless it's some sort of BBEdit artifact (which is what I use to edit the Python attachment).

Posted on
Wed Jun 19, 2019 3:41 pm
FlyingDiver offline
Posts: 3466
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Reload Libraries and Attachments

Mark wrote:
There's now a mystery file, with the same name as my Python attachment script, with suffix "pyc". I didn't create that. Just curious about it. I'm assuming I should leave that alone. Unless it's some sort of BBEdit artifact (which is what I use to edit the Python attachment).


That's the compiled Python file, which is normal for library type files. Just leave it be. It'll get recreated any time you change the .py file.

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

Posted on
Wed Jun 19, 2019 4:55 pm
jay (support) offline
Site Admin
User avatar
Posts: 15693
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload Libraries and Attachments

Mark wrote:
Stopping embedded script executor host (pid 4894)
Stopped "embedded script executor host"
Loading attachments
"update logs.scpt" script loaded


Note that the while the log indicates that one of my AppleScripts got reloaded, it doesn't list the Python script as reloaded (even though it did, in fact, reload).


Python works differently than AppleScript. The latter requires the application to explicitly load the attachment scripts when it starts up. The former just requires that the Python interpreter have the path to that directory added to it's list of paths to search in when a script attempts to import something. So when Indigo starts the interpreter (embedded script executor) nothing actually gets loaded, we just add that directory to the path before starting it. Later, when it runs your script which does an import, it looks in all the paths to find the module you specify in your import.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jun 19, 2019 5:06 pm
Mark offline
User avatar
Posts: 126
Joined: Apr 21, 2005
Location: California

Re: Reload Libraries and Attachments

Thanks for the explanations guys. Good info to have. The whole thing works pretty fast, but it’s interesting that Indigo/Python loads that attachment script after it’s called, instead of having a compiled version waiting in memory. No matter, it’s all working well, and I’m glad I can still store common code in this way.

Posted on
Thu Jun 20, 2019 8:43 am
jay (support) offline
Site Admin
User avatar
Posts: 15693
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload Libraries and Attachments

Mark wrote:
it’s interesting that Indigo/Python loads that attachment script after it’s called, instead of having a compiled version waiting in memory.


That's how Python works (as a dynamic language) - it never loads anything until it's actually needed. As for compilation, that's what that pyc file you were asking about above is (it's how Python optimizes load times), though "compile" isn't exactly the right word... :)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu Jun 20, 2019 8:46 am
FlyingDiver offline
Posts: 3466
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Reload Libraries and Attachments

Depends on your definition of compiled, I guess. It's gets pretty blurry with virtual machines running byte-code directly.

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

Posted on
Thu Jun 20, 2019 9:15 am
Mark offline
User avatar
Posts: 126
Joined: Apr 21, 2005
Location: California

Re: Reload Libraries and Attachments

OK, I'm getting the gist of it. Either way, whether's Indigo is just "recording" the path to the code, or readying a compiled version (the pyc file) and "recording" the path to that, I'd still like to see that event in the log. Just so we can get feedback that Indigo is ready to use whatever it finds in the attachment folder, AppleScript or Python...

Posted on
Thu Jun 20, 2019 10:07 am
jay (support) offline
Site Admin
User avatar
Posts: 15693
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload Libraries and Attachments

Mark wrote:
OK, I'm getting the gist of it. Either way, whether's Indigo is just "recording" the path to the code, or readying a compiled version (the pyc file) and "recording" the path to that, I'd still like to see that event in the log. Just so we can get feedback that Indigo is ready to use whatever it finds in the attachment folder, AppleScript or Python...


Indigo isn't directly doing anything other than setting path parameter when it starts up the Python process. Python is doing everything else without Indigo's knowledge, so there's really nothing to log.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 24, 2019 12:41 pm
tailwheel offline
Posts: 15
Joined: Mar 14, 2007
Location: Colorado

Re: Reload Libraries and Attachments

Selecting the menu 'Plugins>Reload Libraries and Attachments' doesn't work reliably. It fails after a variable number of reloads.

Checking the Activity Monitor, there's more than one instance of ScriptExecutor.indigoPlugin running. If I quit them all, the process starts again.. At this point, trying to Reload via the menu creates a new instance of the ScriptExecutor.indigoPlugin. It appears that each time I try the menu Reload, another ScriptExecutor.indigoPlugin begins.

I have Triggers that utilize my Python Attachment files and wonder if that may be getting in the way of the Reload, or maybe it's something else.

Any ideas?

Best,
Greg

Posted on
Wed Jul 24, 2019 1:45 pm
jay (support) offline
Site Admin
User avatar
Posts: 15693
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Reload Libraries and Attachments

What OS and Indigo versions are you using? Any errors in the Event Log when you select the menu item?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Wed Jul 24, 2019 2:27 pm
tailwheel offline
Posts: 15
Joined: Mar 14, 2007
Location: Colorado

Re: Reload Libraries and Attachments

OS 10.13.6, Indigo 7.3.1. No errors reported in the log.

When the Reload works properly, Indigo presents a small window, briefly. When it fails, there is no such window.

Best,
Greg

Who is online

Users browsing this forum: No registered users and 0 guests