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.

Splitting a Network Event Server payload

If you have a question or need help, this is the place to be.
Post Reply
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Splitting a Network Event Server payload

Post by Mastiff »

After an hour of wasting time I guess I'll have to admit defeat and thrown in the towel and ask for help:

I get a network event that looks like this:

.RadioPuta ['192.168.0.167', u'P1']

I would like to then use .RadioPuta (pillow, not the Spanish meaning...) as a trigger, which is easy. Then I would like to send only the P1 part (the radio channel) in a command line to another program, using it as a command line option in Start application. But using the payload as it is, gives the full payload with the IP and the u, so I have to split it.

I try this:

Code: Select all

eg.event.payload_copy = eg.event.payload
my_data = eg.event.payload_copy.split(' ')

eg.globals.PutaKanal = my_data [2]
Then I try to send it like this:

Code: Select all

"{eg.globals.PutaKanal}"
And it fails miserably:

Code: Select all

21:40:35            Error in Action: "Starte radiokanal via Girder"
21:40:35            Traceback (most recent call last) (1669):
21:40:35              File "C:\Programfiler\EventGhost\eg\Classes\ActionBase.py", line 170, in CallWrapper
21:40:35                return self(*args)
21:40:35              File "C:\Programfiler\EventGhost\plugins\System\Execute.py", line 105, in __call__
21:40:35                arguments = eg.ParseString(arguments)
21:40:35              File "C:\Programfiler\EventGhost\eg\Utils.py", line 204, in ParseString
21:40:35                res = eval(word, {}, eg.globals.__dict__)
21:40:35              File "<string>", line 1, in <module>
21:40:35            AttributeError: 'Bunch' object has no attribute 'PutaKanal'
So where do I mess up?
Javier
Experienced User
Posts: 73
Joined: Sun Dec 01, 2013 3:45 pm

Re: Splitting a Network Event Server payload

Post by Javier »

If you only need the payload try the following,

Code: Select all

eg.event.payload[1]
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Splitting a Network Event Server payload

Post by Mastiff »

So simple, and it works! Thanks! :D
Post Reply