Вопрос

I have a rPi running raspbmc and I created autoexec.py which runs on startup. Inside autoexec.py, I put the following code:

import os
import shutil

shutil.copyfile(/mnt/usb/scripts/guisettings.xml, /home/pi/.xbmc/userdata/guisettings.xml)

However, I am getting an error every time I attempt to run this script. I have checked the log files and it only shows the following:

-->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.SyntaxError'>
Error Contents: ('invalid syntax', ('autoexec.py', 4, 17, 'shutil.copyfile(/mnt/usb/scripts/guisettings.xml, /home/pi$
SyntaxError: ('invalid syntax', ('autoexec.py', 4, 17, 'shutil.copyfile(/mnt/usb/scripts/guisettings.xml, /home/pi/.x$
-->End of Python script error report<--

What am I doing wrong here? I have been attempting this for the past hour.

Это было полезно?

Решение

You need to quote literal strings in Python:

shutil.copyfile('/mnt/usb/scripts/guisettings.xml', 
                '/home/pi/.xbmc/userdata/guisettings.xml')
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top