Page 1 of 1

need help her writing very simple Python script for USB-uirt

Posted: Thu Jul 31, 2014 7:04 pm
by dmehling
I am trying to learn how to do Python scripts, but I cannot find any tutorial. What I am trying to do is quite simple. I'm trying to execute a series of actions for my satellite DVR receiver with USB-uirt. Here are the actions in my macro:

satellite down arrow
wait .5 seconds
satellite delete


I copied and pasted these individual actions into my script, but it's not working. Here is the script:

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
<Action Name="satellite down arrow">
USB_UIRT.TransmitIR(u'0000 006C 0022 0002 0158 00AD 0015 0016 0016 0016 0015 0017 0015 0016 0016 0016 0015 0017 0015 0041 0015 0017 0015 0016 0016 0016 0015 0017 0015 0016 0016 0016 0015 0017 0015 0041 0015 0017 0015 0016 0016 0041 0015 0041 0015 0041 0016 0016 0015 0017 0015 0016 0016 0016 0015 0041 0016 0016 0015 0017 0015 0016 0016 0041 0015 0041 0015 0041 0016 0041 0015 171B 0158 0056 0016 171B', 4, 0)
</Action>
<Action>
EventGhost.Wait(0.5)
</Action>
<Action Name="satellite delete">
USB_UIRT.TransmitIR(u'0000 006E 0022 0002 0153 00AA 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 \n\n0015 0016 0015 0040 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 \n\n0015 0016 0015 0040 0015 0016 0015 0040 0015 0016 0015 0015 0016 0040 0015 0040 \n\n0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0040 0016 0015 0015 0016 \n\n0015 0040 0015 0040 0016 0040 0015 06DC 0153 0055 0016 06DC', 4, 0)
</Action>
</EventGhost>


The error I get in the event log says:

Error compiling script.
Traceback (most recent call last):
SyntaxError: invalid syntax (3, line 1)


Any suggestions on what I'm doing wrong here?

Re: need help her writing very simple Python script for USB-

Posted: Thu Jul 31, 2014 7:16 pm
by krambriw
You cannot do it like that. You shall use 'Copy As Python' when you copy & pase actions into a python script

Re: need help her writing very simple Python script for USB-

Posted: Thu Jul 31, 2014 9:46 pm
by dmehling
Okay, that helps. However, I'm getting the same error in line 1. I copied to Python exactly the code from those three actions:

eg.plugins.sion="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
<Action Name="satellite down arrow">
USB_UIRT.TransmitIR(u'0000 006C 0022 0002 0158 00AD 0015 0016 0016 0016 0015 0017 0015 0016 0016 0016 0015 0017 0015 0041 0015 0017 0015 0016 0016 0016 0015 0017 0015 0016 0016 0016 0015 0017 0015 0041 0015 0017 0015 0016 0016 0041 0015 0041 0015 0041 0016 0016 0015 0017 0015 0016 0016 0016 0015 0041 0016 0016 0015 0017 0015 0016 0016 0041 0015 0041 0015 0041 0016 0041 0015 171B 0158 0056 0016 171B', 4, 0)
eg.plugins.EventGhost.Wait(0.5)
eg.plugins.sion="1.0" encoding="UTF-8" ?>
<EventGhost Version="1610">
<Action Name="satellite delete">
USB_UIRT.TransmitIR(u'0000 006E 0022 0002 0153 00AA 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0016 0015 0040 0015 0016 0015 0015 0016 0040 0015 0040 0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0040 0016 0015 0015 0016 0015 0040 0015 0040 0016 0040 0015 06DC 0153 0055 0016 06DC', 4, 0)


These actions work perfectly when I execute them as part of a macro. So I know that they do work. I just can't seem to translate them into Python.

Re: need help her writing very simple Python script for USB-

Posted: Fri Aug 01, 2014 5:21 am
by krambriw
Please reply with the actual python code you have so far. Mark the text as 'Code' when you paste it into your reply. Like this example:

Code: Select all

This is code

Re: need help her writing very simple Python script for USB-

Posted: Fri Aug 01, 2014 6:53 am
by krambriw
Actually, I think you are not too far away but you need to wipe out the stuff that isn't python code (the remaining xml code should be deleted or commented out).

Your python script could look like this:

Code: Select all

# "satellite down arrow"
eg.plugins.USB_UIRT.TransmitIR(u'0000 006C 0022 0002 0158 00AD 0015 0016 0016 0016 0015 0017 0015 0016 0016 0016 0015 0017 0015 0041 0015 0017 0015 0016 0016 0016 0015 0017 0015 0016 0016 0016 0015 0017 0015 0041 0015 0017 0015 0016 0016 0041 0015 0041 0015 0041 0016 0016 0015 0017 0015 0016 0016 0016 0015 0041 0016 0016 0015 0017 0015 0016 0016 0041 0015 0041 0015 0041 0016 0041 0015 171B 0158 0056 0016 171B', 4, 0)

# just a delay
eg.plugins.EventGhost.Wait(0.5)

# "satellite delete"
eg.plugins.USB_UIRT.TransmitIR(u'0000 006E 0022 0002 0153 00AA 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0016 0015 0040 0015 0016 0015 0015 0016 0040 0015 0040 0015 0016 0015 0015 0016 0015 0015 0016 0015 0040 0015 0040 0016 0015 0015 0016 0015 0040 0015 0040 0016 0040 0015 06DC 0153 0055 0016 06DC', 4, 0)

Re: need help her writing very simple Python script for USB-

Posted: Fri Aug 01, 2014 6:06 pm
by dmehling
Thanks. I just didn't know the basic formatting standards for this type of script. The documentation on the eg website seemed to indicate I needed all of that extra stuff.