| Author |
Message |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
That error shows that you have modified the script from what you originally posted.
Please try compiling the original script above again, then copy/paste any errors you see in the Event Log. Let's not change things while we are trying to troubleshoot -- it just makes everything more complicated for us.
And also copy/paste yet again *exactly* what you are compiling.
_________________
|
| Tue Mar 27, 2012 9:01 am |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
Matt, Compiling this code from the previous post: - Code: Select all
#set coffee timestamp
import datetime applianceLinc = indigo.devices["coffee"] if applianceLinc.onState: indigo.variable.updateValue(862715057, str(datetime.datetime.now()))
Gives this in the log; 2012-03-27 9:18:59 AM Script Error embedded script: invalid syntax Script Error around line 6 - "indigo.variable.updateValue(862715057, str(datetime.datetime.now()))"
|
| Tue Mar 27, 2012 9:20 am |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
Does this compile: - Code: Select all
applianceLinc = indigo.devices["coffee"] if applianceLinc.onState: indigo.variable.updateValue(862715057, "hello")
And what version of OS X are you running?
_________________
|
| Tue Mar 27, 2012 9:30 am |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
Matt, No it doesn't compile. Script Error embedded script: invalid syntax Script Error around line 3 - "indigo.variable.updateValue(862715057, "hello")"
OS X 10.7.2/Python 2.5.6/Indigo 5.0.4
|
| Tue Mar 27, 2012 9:56 am |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
How about just this single line script: - Code: Select all
indigo.variable.updateValue(862715057, "hello")
_________________
|
| Tue Mar 27, 2012 10:00 am |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
No joy, same error; invalid syntax. 
|
| Tue Mar 27, 2012 10:25 am |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
Try: - Code: Select all
foo = "hello" bar = "bye"
And then: - Code: Select all
foo = "hello" bar = "bye" indigo.server.log(foo)
And finally: - Code: Select all
foo = "hello" bar = "bye" indigo.variable.updateValue(862715057, foo) indigo.variable.updateValue(862715057, bar)
Copy/paste the Event Log error results from all three.
_________________
|
| Tue Mar 27, 2012 10:48 am |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
Matt, Won't compile even the first one; script Error embedded script: invalid syntax Script Error around line 1 - "foo = "hello""
|
| Tue Mar 27, 2012 2:09 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
Try: - Code: Select all
foo = 5 indigo.server.log(str(foo))
_________________
|
| Tue Mar 27, 2012 2:21 pm |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
Matt, I'm at home on a different computer with the same versions of Indigo. This code: - Code: Select all
applianceLinc = indigo.devices["coffee"] if applianceLinc.onState: indigo.variable.updateValue(862715057, "hello")
gives this error now; Error script error: around characters 16 to 23 Error script error: A unknown token can’t go after this identifier. (-2740)
this code; - Code: Select all
foo = "hello" bar = "bye" indigo.server.log(foo)
giver error: Error script error: around characters 32 to 33 Error script error: Expected end of line, etc. but found unknown token. (-2741)
The last code you sent; - Code: Select all
foo = 5 indigo.server.log(str(foo))
gives this error: Error script error: around characters 14 to 15 Error script error: Expected end of line, etc. but found unknown token. (-2741)
|
| Tue Mar 27, 2012 3:25 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
Those are all AppleScript errors, which means you don't have python selected from the popup in the UI. Also, make sure you have at least a space character indent on this line: - Code: Select all
indigo.variable.updateValue(862715057, "hello")
since Python requires it.
_________________
|
| Tue Mar 27, 2012 3:33 pm |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
Matt, OK, now it compiles with no errors in the log but it won't write the variable. I copied & pasted the new variable ID into the code so it is correct and the variable exists. - Code: Select all
import datetime applianceLinc = indigo.devices["coffee"] if applianceLinc.onState: indigo.variable.updateValue(717445627, str(datetime.datetime.now()))
|
| Tue Mar 27, 2012 3:56 pm |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6642 Location: Austin, Texas
|
 Re: Help converting a simple applescript to Python
You still have a problem - the line after the "if" line needs to be indented by at least one space. Blocks in Python are delineated by indentation. - Code: Select all
import datetime applianceLinc = indigo.devices["coffee"] if applianceLinc.onState: indigo.variable.updateValue(717445627, str(datetime.datetime.now()))
4 spaces is generally considered standard form for Python.
_________________ Jay (Indigo Support)
|
| Tue Mar 27, 2012 4:53 pm |
|
 |
|
matt (support)
Site Admin
Joined: Jan 27, 2003 Posts: 11671 Location: Texas
|
 Re: Help converting a simple applescript to Python
It would be most helpful if you could explain what it is you changed to get it compiling -- it wasn't just the change from AppleScript to Python because your other posts on this forum thread are showing python errors, I believe. We've spent some time with you troubleshooting this and it would be good to know for other customers that might run across the same problem.
_________________
|
| Tue Mar 27, 2012 5:07 pm |
|
 |
|
bob
Joined: Jun 14, 2006 Posts: 500
|
 Re: Help converting a simple applescript to Python
Matt,
I truly appreciate all your help.
I didn't change anything to get it to compile, I have no idea why it is compiling. I just switched to a different computer (old mac pro) when I got home from work (new AirBook). Same OS X version, same Indigo version. Even though it compiles on this computer it won't write to the variable.
The line after the "if" is indented. I tried changing to a new variable/ID but it still won't write and I don't get errors in the log.
I have no idea what to do.
|
| Tue Mar 27, 2012 5:36 pm |
|
|