Any way to copy a file?
#1
I found this script on the forum to change skins and it works like a champ. What I would like to add at line 8 is a way to copy a modified settings.xml and replace the existing file before switching back to the skin at the end of the script. I have a handful of modified settings.xml files in subdirectories of the skin folder in addon_data. I couldn't find an example of this anywhere. Is this possible?

XML:

import xbmc, xbmcgui
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue","id":1,"params":{"setting":"lookandfeel.skin","value":"skin.estuary"}}')
xbmc.sleep(1000)
xbmc.executebuiltin('SendClick(11)')
dialog = xbmcgui.Dialog()
dialog.ok("Skin Changer", "CLICK OK TO CHANGE SKIN SETTINGS")
xbmc.sleep(1000)
COPY COMMAND HERE...
xbmc.sleep(1000)
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue","id":1,"params":{"setting":"lookandfeel.skin","value":"skin.aeonmq8.matrix.mod"}}')
xbmc.sleep(1000)
xbmc.executebuiltin('SendClick(11)')
dialog = xbmcgui.Dialog()
dialog.ok("Skin Changer", "NEW SKIN SETTINGS LOADED!")
Reply
#2
As the script you found is a python script, you just need to google how it's possible to copy files using python. Maybe this is of any help as a starter: 

https://www.techbeamers.com/python-copy-file/

especially: 

https://www.techbeamers.com/python-copy-file/#os-system
Reply
#3
Thanks @DaVu. After digging through the forum, I found an example and it does exactly what I want. Here is my tweaked version if anyone is interested...

xml:

#Change the Skin to Estuary so we can load the new MQ 8 settings
import xbmc, xbmcgui
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue","id":1,"params":{"setting":"lookandfeel.skin","value":"skin.estuary"}}')
xbmc.sleep(1000)
xbmc.executebuiltin('SendClick(11)')

#Copy the Standard settings
import shutil
src = xbmc.translatePath('special://home/userdata/addon_data/skin.aeonmq8.matrix.mod/Standard/settings.xml')
dst = xbmc.translatePath('special://home/userdata/addon_data/skin.aeonmq8.matrix.mod/settings.xml')
backup = xbmc.translatePath('special://home/userdata/addon_data/skin.aeonmq8.matrix.mod/backup/settings.xml')
#Last chance to exit!
dialog = xbmcgui.Dialog().yesno("Load the standard settings for MQ 8","Are you sure you want to continue?","No")
if dialog:
shutil.copyfile(dst, backup)
shutil.copyfile(src, dst)
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue","id":1,"params":{"setting":"lookandfeel.skin","value":"skin.aeonmq8.matrix.mod"}}')
xbmc.sleep(1000)
xbmc.executebuiltin('SendClick(11)')
dialog = xbmcgui.Dialog()
dialog.ok("Skin settings update", "New Skin settings loaded")
else:
xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Settings.SetSettingValue","id":1,"params":{"setting":"lookandfeel.skin","value":"skin.aeonmq8.matrix.mod"}}')
xbmc.sleep(1000)
xbmc.executebuiltin("ActivateWindow(10000,return)")
xbmc.executebuiltin('SendClick(11)')
dialog = xbmcgui.Dialog()
dialog.ok("Skin settings update", "Skin settings update aborted")
Reply

Logout Mark Read Team Forum Stats Members Help
Any way to copy a file?0