Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

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

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
dmehling
Posts: 29
Joined: Wed Jun 24, 2009 12:10 am

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

Post 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?
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

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

Post by krambriw »

You cannot do it like that. You shall use 'Copy As Python' when you copy & pase actions into a python script
dmehling
Posts: 29
Joined: Wed Jun 24, 2009 12:10 am

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

Post 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.
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

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

Post 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
krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

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

Post 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)
dmehling
Posts: 29
Joined: Wed Jun 24, 2009 12:10 am

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

Post 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.
Post Reply