Creating library routines

Posted on
Mon Oct 31, 2016 5:12 pm
beaker offline
Posts: 19
Joined: Apr 30, 2016

Creating library routines

I'm trying to create a set of library routines that I can call from my Python scripts (via a file, not embedded script), and I haven't been able to get it working.

I've created the "indigoAttachments.py" file given in the examples (with a slight change for Python 2.7 vs 2.5 in the example):

Code: Select all
#!/usr/bin/env python2.7
"""
indigoAttachments.py

In this file you can insert any methods and classes that you define.
They will be shared by all Python scripts - you can even import the
IOM (as shown below) but if you do then you'll only be able to import
this script in Python processes started by Indigo. If you don't need
the IOM then skip the import and it'll work in any Python script
no matter where it's run from.
"""

try:
    import indigo
except ImportError:
    print "Attachments can only be used from within Indigo"
    raise ImportError

def specialLog(text):
    indigo.server.log(text, type="indigoAttachments")


... and placed it in /Volumes/Macintosh HD/Library/Python/2.7/site-packages, but when I add "import indigoAttachments" to the top of my script, I get a script error that says "No module named indigoAttachments".

From what I understand, the "indigoAttachments.py" file will be loaded whenever the Python interpreter is loaded. I've tried restarting the Indigo server, but I get the same behavior.

I'm running MacOS 10.11.6 (El Capitan), Indigo 6.1.7, and Python 2.7.10. I checked using Terminal and the script is marked as executable.

If I go into Python on the server and execute "import indigoAttachments", it works as expected (I get the 'Attachments can only be used from within Indigo' message).

Am I doing something wrong, or should this work?

Posted on
Mon Oct 31, 2016 6:36 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Creating library routines

Indigo 6 uses Python 2.6, not 2.7... ;)

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon Oct 31, 2016 6:45 pm
beaker offline
Posts: 19
Joined: Apr 30, 2016

Re: Creating library routines

That did it - thanks, Jay!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 15 guests

cron