Plugin.py help please

Forum rules

This is a legacy forum which is locked for new topics. New topics should be started in one of the other forums under Extending Indigo

Posted on
Mon Mar 25, 2013 9:07 am
jd10884 offline
Posts: 39
Joined: Feb 18, 2012

Plugin.py help please

The script below runs fine when run in a Python 2.5 Editor but throws wobbler when run in Indigo 5. The error is;

Script Error Error in plugin execution compileExecuteSource:

Traceback (most recent call last):
File "plugin.py", line 201, in compileExecuteSource
File "plugin.py", line 190, in _compileExecuteSource
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'lstrip'

Can you tell me why Indigo's plugin.py doesn't like the script?

Code: Select all
from __future__ import with_statement
from datetime import date
import linecache
import os

fileDate = str(date.today())

theBody = []

baseDir = '/Library/Application Support/Perceptive Automation/Indigo 5/Logs'
tmpFileName = os.path.join(baseDir, 'tmp.txt')
log = os.path.join(baseDir, fileDate + ' Events.txt')

with open(tmpFileName) as tmpFile:
    prenumLines = sum(1 for line in tmpFile)

with open(tmpFileName, 'w') as tmpFile:
    with open(log, 'r') as logFile:
        for line in logFile:
            if 'Error' in line:   
                tmpFile.write(line )

with open(tmpFileName) as tmpFile:
    postnumLines = sum(1 for line in tmpFile)
lineNum  = prenumLines

with open(tmpFileName) as tmpFile:
    while lineNum < postnumLines:
        theBody.append(linecache.getline(tmpFileName, lineNum + 1) )
        lineNum = lineNum + 1


#theBody is the body of  an email to be sent next
theBody =  "".join(theBody)

Posted on
Mon Mar 25, 2013 12:04 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Plugin.py help please

Indigo has to wrap the script code inside a function before it can execute it, which is causing it to fail on this line:

Code: Select all
from __future__ import with_statement

I just modified Indigo (for next beta) to automatically include the with statement __future__ import for all script code it executes. So once that is released your script will run after you delete the first line.

In the mean time the workaround would be to both remove the first line and remove the usage of the with statements.

Image

Posted on
Mon Mar 25, 2013 3:04 pm
jd10884 offline
Posts: 39
Joined: Feb 18, 2012

Re: Plugin.py help please

Matt,

Will this addition be available in Indigo 5 with the next update?

Thanks
Jeff

Posted on
Mon Mar 25, 2013 3:22 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Plugin.py help please

Hi Jeff,

Under Indigo 5 you'll need to use the workaround (no with statements).

Image

Posted on
Mon Mar 25, 2013 4:48 pm
jd10884 offline
Posts: 39
Joined: Feb 18, 2012

Re: Plugin.py help please

Matt,

Hmmmmmmmm Thats not what I was really hoping to hear, I was hoping to hear that Indigo 5 was going to be supported and there was not going to be any reason to upgrade to 6. Is there any reason why 5 could not be integrated into the update so the Python functionality that was supposed to be supported in Indigo 5 could be supported rather than having to create workarounds?

Jeff

Posted on
Mon Mar 25, 2013 5:30 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Plugin.py help please

Yes - the code change was non-trivial and given that there's a simple workaround we don't believe that back-porting the change is critical (particularly given that this is the first time we've seen this problem and Indigo 5 has been on the market almost 2 years).

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests