1

I have written the following really simple python script to change the desktop wallpaper on my mac (based on this thread):

from appscript import app, mactypes
import sys 

fileName = sys.argv[1:]

app('Finder').desktop_picture.set(mactypes.File(fileName))

However when I run it I get the following output:

Traceback (most recent call last):
File "../Source/SetWallPaper2.py", line 6, in app('Finder').desktop_picture.set(mactypes.File(fileName)) File "/Library/Python/2.5/site-packages/appscript-0.19.0-py2.5-macosx-10.5-i386.egg/appscript/reference.py", line 513, in call appscript.reference.CommandError: Command failed: OSERROR: -10000 MESSAGE: Apple event handler failed. COMMAND: app(u'/System/Library/CoreServices/Finder.app').desktop_picture.set(mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']"))

I've done some web searching but I can't find anything to help me figure out what OSERROR -10000 means or how to resolve the issue.

Danielb
  • 1,608
  • 5
  • 24
  • 34

1 Answers1

2

fileName = sys.argv[1] instead of fileName = sys.argv[1:]

mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']")

See the square brackets and quotes around the filename?

TML
  • 12,813
  • 3
  • 38
  • 45