Plugin.py help please

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
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
jd10884
Posts: 39
Joined: Sat Feb 18, 2012 2:24 pm

Plugin.py help please

Post by jd10884 »

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)
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Plugin.py help please

Post by matt (support) »

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
jd10884
Posts: 39
Joined: Sat Feb 18, 2012 2:24 pm

Re: Plugin.py help please

Post by jd10884 »

Matt,

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

Thanks
Jeff
User avatar
matt (support)
Site Admin
Posts: 21542
Joined: Mon Jan 27, 2003 1:17 pm
Location: Texas
Contact:

Re: Plugin.py help please

Post by matt (support) »

Hi Jeff,

Under Indigo 5 you'll need to use the workaround (no with statements).
Image
jd10884
Posts: 39
Joined: Sat Feb 18, 2012 2:24 pm

Re: Plugin.py help please

Post by jd10884 »

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
User avatar
jay (support)
Site Admin
Posts: 19232
Joined: Wed Mar 19, 2008 11:52 am
Location: Austin, Texas
Contact:

Re: Plugin.py help please

Post by jay (support) »

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
Locked

Return to “Extending Indigo with Plugins and Python”