webserver plugin and eg.event.payload
Posted: Thu Apr 19, 2012 6:03 pm
Hi there,
i┬┤m sending my href in the format "http://192.168.1.39/index.html?HTTPMasterVolume&11&0" to EG┬┤s webserver.
the purpose is to trigger the Master Volume in a Python Script with
the result is an error
when i print (eg.event.payload) with
the result in the log is
As EG┬┤s webserver supposedly is expecting
and eg.event.payload comes with [u'11', u'0'] this error makes sense to me.
The question is: how could i get rid of the u' in the payload?
Thank you for any hints
best
H.
EDIT:
i could manage to strip down [u'11', u'0'] to 11 with
but still its not working 
EDIT2:
Ok, i managed it by myself. I had to convert from unicode. i┬┤m shure there is a nicer way but due my lack of knowledge of Python i have to go step by step
i┬┤m sending my href in the format "http://192.168.1.39/index.html?HTTPMasterVolume&11&0" to EG┬┤s webserver.
the purpose is to trigger the Master Volume in a Python Script with
Code: Select all
eg.WinApi.SoundMixer.SetMasterVolume(eg.event.payload)Code: Select all
Traceback (most recent call last):
Python script "64", line 1, in <module>
eg.WinApi.SoundMixer.SetMasterVolume(eg.event.payload)
File "C:\Programme\EventGhost\eg\WinApi\SoundMixer.py", line 201, in SetMasterVolume
newValue = int((value / 100.0) * (maximum - minimum)) + minimum
TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'when i print (eg.event.payload) with
Code: Select all
print (eg.event.payload)Code: Select all
[u'11', u'0']Code: Select all
eg.WinApi.SoundMixer.SetMasterVolume(x.0, 0)The question is: how could i get rid of the u' in the payload?
Thank you for any hints
best
H.
EDIT:
i could manage to strip down [u'11', u'0'] to 11 with
Code: Select all
str = eg.event.payload
print str
vol = str[0]
print vol
eg.plugins.System.SetMasterVolume((vol), 0)EDIT2:
Ok, i managed it by myself. I had to convert from unicode. i┬┤m shure there is a nicer way but due my lack of knowledge of Python i have to go step by step
Code: Select all
str = eg.event.payload
vol = str[0]
mastervolnew = float(vol)
print "New MasterVolume = ", mastervolnew
eg.plugins.System.SetMasterVolume(mastervolnew, 0)