Newbie question: how do I properly end a script?
#19
the problem is that you try to re execute a script with "running" label.
it will make the script fail.

to prevent that, i changed my default.py, now it works like a script launcher.

if the file exist, will ask if you want to end it.
if not, run the script with xbmc.executebuiltin so the 'launcher script" will end end won't have "running label"

here my default.py code:

Code:
# -*- coding: cp1252 -*-

# script constants
__script__       = "Sportlive"
__author__       = "Ppic"
__url__          = "http://code.google.com/p/passion-xbmc/"
__svn_url__      = "http://passion-xbmc.googlecode.com/svn/trunk/scripts/"
__credits__      = "Team XBMC passion, http://passion-xbmc.org/developpement-python/%28script%29-sporlive-display/"
__platform__     = "xbmc media center, [LINUX, OS X, WIN32, XBOX]"
__date__         = "09-01-2010"
__version__      = "1.5"
__svn_revision__  = "$Revision$".replace( "Revision", "" ).strip( "$: " )
__XBMC_Revision__ = "20000" #XBMC Babylon
__useragent__    = "Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"



import os
import time
import xbmc
import xbmcgui
from traceback import print_exc

BASE_RESOURCE_PATH = os.path.join( os.getcwd(), "resources" )

process = os.path.join( BASE_RESOURCE_PATH , "sportilve.pid")
if os.path.exists(process):
    if xbmcgui.Dialog().yesno("Sportlive est déjà en cours", "Voulez-vous stopper la surveillance?" ):
        os.remove(process)        
else:
    file( process , "w" ).write( "" )
    xbmc.executebuiltin('XBMC.RunScript(%s)' % os.path.join( os.getcwd(), "sportlive.py" ))

in the launched script, i have a loop that seek for the .pid file, if it not there it ends.

this way, i can start the script for changing my filters without stopping the script that run backend (filters are stored in file)
Reply


Messages In This Thread
[No subject] - by VictorV - 2010-01-05, 13:04
[No subject] - by brulsmurf - 2010-01-05, 13:35
Maybe not so easy then? - by brulsmurf - 2010-01-06, 21:20
[No subject] - by blittan - 2010-01-06, 21:32
[No subject] - by brulsmurf - 2010-01-07, 11:01
[No subject] - by rwparris2 - 2010-01-07, 13:42
[No subject] - by brulsmurf - 2010-01-07, 14:19
[No subject] - by brulsmurf - 2010-01-07, 22:10
[No subject] - by jmarshall - 2010-01-08, 00:06
[No subject] - by blittan - 2010-01-08, 02:36
[No subject] - by ppic - 2010-01-08, 02:41
[No subject] - by blittan - 2010-01-08, 03:19
[No subject] - by LtChambers - 2010-01-08, 03:58
[No subject] - by brulsmurf - 2010-01-08, 09:07
[No subject] - by blittan - 2010-01-08, 09:56
[No subject] - by brulsmurf - 2010-01-08, 21:13
[No subject] - by blittan - 2010-01-08, 23:56
[No subject] - by ppic - 2010-01-09, 22:20
[No subject] - by brulsmurf - 2010-01-09, 22:26
[No subject] - by ppic - 2010-01-11, 01:31
[No subject] - by brulsmurf - 2010-01-25, 11:03
[No subject] - by matthuisman - 2010-01-26, 01:28
[No subject] - by matthuisman - 2010-01-26, 01:30
[No subject] - by brulsmurf - 2010-01-26, 09:17
[No subject] - by matthuisman - 2010-01-26, 23:28
[No subject] - by brulsmurf - 2010-01-27, 21:32
Logout Mark Read Team Forum Stats Members Help
Newbie question: how do I properly end a script?0