29.10.2015, 03:51
Irgendwie geht das mehrfach property nicht.
Das Script schaut im Moment so aus:
Das Script schaut im Moment so aus:
Spoiler!
Code:
#Name: HelgeInterface
#Version: v0.1
#Owner: harryberlin
import sys, urllib
import xbmc, xbmcgui
#DEBUG = True
HI_CLASS = ['OBC', 'IKE', 'IBUS']
HI_METHOD_OBC = ['Refresh', 'Reset', 'Set']
HI_METHOD_IKE = ['Displaytext']
HI_METHOD_IBUS = ['SendMSG']
HI_METHOD = [HI_METHOD_OBC, HI_METHOD_IKE, HI_METHOD_IBUS]
####################### -- Functions -- #######################
def Debug(sTring1,sTring2='',sTring3=''):
try:
if DEBUG: xbmcgui.Dialog().ok(str(sTring1), str(sTring2), str(sTring3))
except:
return
def HI_JSON( sClass, sMethod, sProperty ):
Debug("got JSON arguments", sMethod, sProperty)
ip = '127.0.0.1'
port = '44000'
sClass_tmp = str(sClass)
sMethod_tmp = str(sMethod)
sClassMethod_tmp = sClass_tmp + '.' + sMethod_tmp
sProperty_tmp = str(sProperty)
Debug('before', sProperty_tmp)
if sMethod in [HI_METHOD_OBC[0],HI_METHOD_OBC[1]]:
sProperty_tmp = sProperty.split(',')
sProperty_tmp = ', "Property": '.join(sProperty_tmp)
Debug('after', sProperty_tmp)
try:
urllib.urlopen('http://' + ip + ':' + port + '/jsonrpc?request={"jsonrpc": "2.0", "method": "' + sClassMethod_tmp + '", "params": { "Property": ' + sProperty_tmp + ' }, "id": 0}', [0])
except:
return
##################### -- programm -- #####################
count = len(sys.argv) - 1
if count < 1:
Debug("No arguments given", "You must specify arguments to the script", "i.e. 'tether_toggle' - to toggle wifi tethering, etc")
else:
aMethod = str(sys.argv[1]).split(".")
# parse Class and set Index
if aMethod[0] in HI_CLASS:
iHI_CLASS_INDEX = int(HI_CLASS.index(aMethod[0]))
Debug("", "CLASS is OK ", aMethod[0])
else:
Debug("unknown arguments given", " - ".join(sys.argv))
pass
# parse Method and set Index
if aMethod[1] in HI_METHOD[iHI_CLASS_INDEX]:
iHI_METHOD_INDEX = int(HI_METHOD[iHI_CLASS_INDEX].index(aMethod[1]))
Debug("good parameter given", ".".join(aMethod), sys.argv[2])
else:
Debug("combined arguments bad", "don't combine Class - Method" , str(aMethod[0]) + " - " + str(aMethod[1]))
pass
# send as json
HI_JSON(aMethod[0], aMethod[1], sys.argv[2])
pass