Why does this script freeze XBMC

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
dennis Offline
Junior Member
Posts: 7
Joined: Jun 2004
Reputation: 0
Post: #21
elupus Wrote:Yup

Thank you, superb.

Havn't tried it yet, running XBMCLive. Is there a way to upgrade the Live installation to the newest build?
(This post was last modified: 2010-05-23 20:45 by dennis.)
find quote
dennis Offline
Junior Member
Posts: 7
Joined: Jun 2004
Reputation: 0
Post: #22
Would this work? I looked at some examples of an asyncore server. The actual code works but I can't try the xbmc.abortRequested boolean, because I'm on the wrong XBMC version.


I'm not a programmer so bare with me.
Tips on the code is welcome.


PHP Code:
import socketthreadingthreadsysasyncorexbmcxbmcgui
from time import 
*
from string import *

TIMEOUT 15
PORT 
10629

class showCaller(xbmcgui.WindowDialog):
    
def __init__(self):
        
self.getWidth()
        
self.getHeight()
        
self.addControl(xbmcgui.ControlImage(490240420170'special://home/scripts/CallerID/frame.png'))
        
self.addControl(xbmcgui.ControlLabel(47522938020'Nummerpresentation''font13''0xffffffff'))
        
self.addControl(xbmcgui.ControlLabel(470173302128data'font14''0xff000000'))
        
self.= -1
        self
.shown 1
        subThread 
threading.Thread(target=self.SubthreadProcargs=())
        
subThread.start()

    
def SubthreadProc(self):
        
sleep(TIMEOUT)
        if 
self.shown:
            
self.close()

    
def onAction(selfaction):
        if 
self.== action:
            
self.shown 0
            self
.close()
        
self.action

class Server(asyncore.dispatcher):
    
def __init__(selfhostport):
        
asyncore.dispatcher.__init__(self)
        
self.create_socket(socket.AF_INETsocket.SOCK_STREAM)
        
self.bind((hostport))
        
self.listen(1)

    
def handle_accept(self):
        
socketaddress self.accept()
        
ConnectionHandler(socket)

    
def handle_close(self):
        
self.close()

class 
ConnectionHandler(asyncore.dispatcher_with_send):
    
def handle_read(self):
        
self.buffer self.recv(1024)
        
self.buffer split(self.buffer[5:], "~")
        
self.close()
        global 
data
        
if len(self.buffer) > 1:
            
name self.buffer[0]
            
number self.buffer[1]
            
data number "\n" name
            w 
showCaller()
            
w.doModal()
            
del w
        
else:
            
data self.buffer

Server(''PORT)

try:
    
asyncore.loop(timeout=2)
except xbmc.abortRequested == true:
    
s.close()
    
sys.exit() 
find quote
elupus Offline
Team-XBMC Developer
Posts: 3,764
Joined: Mar 2004
Reputation: 2
Post: #23
Hmm.. Sort of doubt it. We don't actually throw an exception. We only set that variable to true.

You should probably do.
PHP Code:
while not xbmc.abortRequested:
    
asynccore.loop(timeout=1)

s.close()
sys.exit() 

That way the abortRequested function is checked once every second.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


[Image: badge.gif]
find quote
dennis Offline
Junior Member
Posts: 7
Joined: Jun 2004
Reputation: 0
Post: #24
Like this?

PHP Code:
import socketthreadingthreadsysasyncorexbmcxbmcgui
from time import 
*
from string import *

TIMEOUT 15
PORT 
10629

class showCaller(xbmcgui.WindowDialog):
    
def __init__(self):
        
self.getWidth()
        
self.getHeight()
        
self.addControl(xbmcgui.ControlImage(490240420170'special://home/scripts/CallerID/frame.png'))
        
self.addControl(xbmcgui.ControlLabel(47522938020'Nummerpresentation''font13''0xffffffff'))
        
self.addControl(xbmcgui.ControlLabel(470173302128data'font14''0xff000000'))
        
self.= -1
        self
.shown 1
        subThread 
threading.Thread(target=self.SubthreadProcargs=())
        
subThread.start()

    
def SubthreadProc(self):
        
sleep(TIMEOUT)
        if 
self.shown:
            
self.close()

    
def onAction(selfaction):
        if 
self.== action:
            
self.shown 0
            self
.close()
        
self.action

class Server(asyncore.dispatcher):
    
def __init__(selfhostport):
        
asyncore.dispatcher.__init__(self)
        
self.create_socket(socket.AF_INETsocket.SOCK_STREAM)
        
self.bind((hostport))
        
self.listen(1)

    
def handle_accept(self):
        
socketaddress self.accept()
        
ConnectionHandler(socket)

    
def handle_close(self):
        
self.close()

class 
ConnectionHandler(asyncore.dispatcher_with_send):
    
def handle_read(self):
        
self.buffer self.recv(1024)
        
self.buffer split(self.buffer[5:], "~")
        
self.close()
        global 
data
        
if len(self.buffer) > 1:
            
name self.buffer[0]
            
number self.buffer[1]
            
data number "\n" name
            w 
showCaller()
            
w.doModal()
            
del w
        
else:
            
data self.buffer

Server(''PORT)


while 
not xbmc.abortRequested:
    
asyncore.loop(timeout=1)

s.close()
sys.exit() 

All I get is "'module' object has no attribute 'abortRequested'", probably because I'm not on the right version?
(This post was last modified: 2010-05-24 20:27 by dennis.)
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #25
OT: sorry

elupus since your in those files would you consider this patch

http://trac.xbmc.org/ticket/9290

or a variant to fix the issue described in the ticket or
http://forum.xbmc.org/showthread.php?tid=70349&highlight=python

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,917
Joined: Dec 2004
Reputation: 17
Post: #26
dennis print xbmc.abortRequested works for me.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Post Reply