Why does this script freeze XBMC

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
elupus Offline
Team-XBMC Developer
Posts: 3,799
Joined: Mar 2004
Reputation: 3
Post: #16
Yup

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
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #17
the script start from startup.xml works good now, thanks.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Waffa Offline
Posting Freak
Posts: 1,163
Joined: May 2008
Reputation: 7
Location: Netherlands
Post: #18
Hey, Nuka1195 why do you already start those scripts in startup.xml ?

Does it speed up loading home.xml ?

I run a animated image in MM Waffa! startup and would be nice if those scripts start while you see the animation and have them ready in homescreen so it would take less time to load Home.xml.

Recently added is always the last that pops up and takes some time (extra).
(This post was last modified: 2010-05-23 17:52 by Waffa.)
find quote
Nuka1195 Offline
Skilled Python Coder
Posts: 3,910
Joined: Dec 2004
Reputation: 18
Post: #19
OT:

i run it from there to start because i don't like running it everytime i enter home.

advantages:
it only runs every half an hour and doesn't run everytime you enter home.

disadvantages:
if you watch a movie then it may still appear in your recently added until the script is scheduled to run. plus if you update database it won't update until the script is run.

the update can be handled by running the script after a scan, from the scanning dialog. i think ronnie or someone came up with that.

not sure what the best way to do it, other than a new feature to xbmc, that can run commands based on an event.

For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
find quote
Waffa Offline
Posting Freak
Posts: 1,163
Joined: May 2008
Reputation: 7
Location: Netherlands
Post: #20
TY !

Going to play with it Smile
find quote
dennis Offline
Junior Member
Posts: 10
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: 10
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,799
Joined: Mar 2004
Reputation: 3
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: 10
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,910
Joined: Dec 2004
Reputation: 18
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,910
Joined: Dec 2004
Reputation: 18
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