Hello,
My name is Jonathan and I would like to be able to run a shell script file after saving and an other after restoring.
I want to save and copy some files after stopping a service and then start again this service.
In settings.xml I had the last 4 lines
Code:
<category id="selection" label="30012">
...
<setting id="custom_dir_2_enable" type="bool" label="30037" default="false" />
<setting id="backup_custom_dir_2" type="folder" label="30018" default="" visible="eq(-1,true)"/>
<setting id="custom_script_save_enable" type="bool" label="30100" default="false" />
<setting id="backup_custom_script_save_enable" type="file" label="30018" default="" visible="eq(-1,true)"/>
<setting id="custom_script_restore_enable" type="bool" label="30101" default="false" />
<setting id="backup_custom_script_restore_enable" type="file" label="30018" default="" visible="eq(-1,true)"/>
In strings.xml, I had the last 3 lines:
Code:
<strings>
<string id="30086">This version of XBMC is different than the one used to create the archive</string>
<string id="30100">Script to run after saving</string>
<string id="30101">Script to run after restoring</string>
<string id="30102">Run the script</string>
In backup.py, it's difficult for me because I don't know where to find the xmbcgui xbmc ...functions.
After "#check if there are custom directories", I had
Code:
import os
import subprocess
#check if there is a custom script to run after saving
if(utils.getSetting('custom_script_save_enable') == 'true' and utils.getSetting('backup_custom_script_save_enable') != ''):
if(not os.path.exists(utils.getSetting('backup_custom_script_save_enable'))):
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30102),utils.getSetting('backup_custom_script_save_enable'))
return
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30084),utils.getSetting('backup_custom_script_save_enable'))
subprocess.call("."+utils.getSetting('backup_custom_script_save_enable'), shell=True)
# os.system(utils.getSetting('backup_custom_script_save_enable'))
Could you please help me to launch a script from backup.py? and to prompt if there was an error at which line of the script?
Thanks in advance