2010-08-25, 10:55
hi again
i have another problem with my script
this is my script:
what he does he open a list of radiobutton
i have a function call changestate that when user click on a button the function onClick call the changestate function and the changestate open a url with php and the php update the database.
the problem is when i call the changeState function fron onCLick he doesnt open the php (i know becuse i dont see change in database) but when i call the the changeState function from somwhere elese in code (main , openroom function) he dose call the php
i dont know waht the problem , i try to do a lot of think and nothing help
anyone know how to solve it
Thank yuo ver much
ofer
i have another problem with my script
this is my script:
Code:
import xbmc, xbmcgui, xbmcplugin, urllib2, urllib, re, string, sys, os,threading
HEADER = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2'
_ELEMENT_ID=[]
_ELEMENT_STATUS=[]
_CARD_ID=[]
_HARD_ID=[]
class openRoomWindow(xbmcgui.WindowXML):
def onInit(self):
update_element(self)
def onClick(self, controlID):
#urllib.urlopen('http://localhost/xbmc/changestate.php?hardid=1&cardid=204&status=1').read()
index= _ELEMENT_ID.index(str(controlID))
cardid=_CARD_ID[index]
hardid=_HARD_ID[index]
status=self.getControl(controlID).isSelected()
changeState()
def update_element(self):
count=0
for temp in _ELEMENT_ID:
self.getControl( int(temp) ).setSelected(int(_ELEMENT_STATUS[count]))
count=count+1
def changeState():
#req=urllib2.Request('http://localhost/xbmc/changestate.php?hardid=1&cardid=204&status=1')
#temp=urllib.request.urlopen('http://localhost/xbmc/changestate.php?hardid=1&cardid=204&status=1')
#fileHandle = urllib2.urlopen('http://localhost/xbmc/changestate.php?hardid=1&cardid=204&status=1')
#str1 = fileHandle.read()
# str1.close()
#req.add_header('User-Agent', HEADER)
#print "good morning"
return urllib2.urlopen(urllib2.Request('http://localhost/xbmc/changestate.php?hardid=1&cardid=204&status=1'))
def openroom():
req=urllib2.Request('http://localhost/xbmc/GetElements.php?roomid=208')
req.add_header('User-Agent', HEADER)
response=urllib2.urlopen(req)
data=response.read()
rooms=re.compile('<controls>(.+?)</controls>', re.DOTALL).findall(data)
global _ELEMENT_ID
global _HARD_ID
global _CARD_ID
global _ELEMENT_STATUS
_ELEMENT_ID=re.compile('<id>(.+?)</id>').findall(rooms[0])
_ELEMENT_STATUS=re.compile('<status>(.+?)</status>').findall(rooms[0])
_CARD_ID=re.compile('<cardid>(.+?)</cardid>').findall(rooms[0])
_HARD_ID=re.compile('<hardid>(.+?)</hardid>').findall(rooms[0])
ui = openRoomWindow('filename.xml', 'C:\Program Files\XBMC\scripts\Contec\default.py')
ui.doModal()
def fixpath(path):
l=len(path)
spath="http://localhost"+path[4:l]
return spath
#main()
#changeState(1,1,1)
#changeState(1,1,1)
changeState()
openroom()
what he does he open a list of radiobutton
i have a function call changestate that when user click on a button the function onClick call the changestate function and the changestate open a url with php and the php update the database.
the problem is when i call the changeState function fron onCLick he doesnt open the php (i know becuse i dont see change in database) but when i call the the changeState function from somwhere elese in code (main , openroom function) he dose call the php
i dont know waht the problem , i try to do a lot of think and nothing help
anyone know how to solve it
Thank yuo ver much
ofer