Launching script via remote and debugging help
#1
Good morning,

I have sortTV set up to run every few hours, and I have a button on my remote programmed to update my library. But I am trying to write a little python script that combines the 2 activities, so that when I press the update library button on my remote the script activates my sort TV bat file, waits a few seconds and then updates the library.

This is the first time I have looked at python, so bare with me.

Quote: import xbmc
import os.system
import time

xbmc.executebuiltin(' Notification(Updater, Update process underway, 5) ')

os.system("C:\\strawberrry\\Z_Sort_TV\\SorTV.bat")

time.sleep(10)
#10 second sleep

xbmc.executebuiltin('UpdateLibrary(video)')
xbmc.executebuiltin('CleanLibrary(video)')

I think this will work, but can any one spot any obvious faults?

The next question how do I launch this from my keyboard.xml? I think it works like this:
Quote:<d mod="ctrl,alt"> xbmc.executescript('C:\\Program Files\\XBMC\\Scripts\\Updater.py')</d>

Is that right? Is there a way to use a relative path to the script (rather than absolute path)?
Reply
#2
Hi guys,

I got all the xbmc stuff working (can fire the script from xbmc and notification pop up correctly etc) but cant get the bat script to execute:

Quote:import os

os.chdir('c:\strawberrry\Z_Sort_TV')
os.system('SortTV.bat')

I have tried single quotes ', double quotes ", with chdir, without chdir nothing seems to work.Huh

I have googled my ass off, but they all just say os.system() will do it.

Some one please help Sad
Reply
#3
Just a guess, but maybe you have to execute cmd.exe with the batch file as parameter, since the batch file itself isn't really a executable.
Reply
#4
It was to do with the windows file system... I don't really understand it, but if you put a "r" in front of the path it magically works.
Quote:os.system(r"C:\strawberry\Z_Sort_TV\SortTV.bat")

I also simplified it to a single line once I found the problem.
Reply

Logout Mark Read Team Forum Stats Members Help
Launching script via remote and debugging help0