“OSERROR -10000 Apple 事件处理程序失败” 尝试更改 Mac 上的桌面壁纸时
我编写了以下非常简单的 python 脚本来更改我的 mac 上的桌面壁纸(基于此 线程):
from appscript import app, mactypes
import sys
fileName = sys.argv[1:]
app('Finder').desktop_picture.set(mactypes.File(fileName))
但是,当我运行它时,我得到以下输出:
回溯(最近一次调用最后一次):
文件“../Source/SetWallPaper2.py”, 6号线,在 app('Finder').desktop_picture.set(mactypes.File(文件名)) 文件 “/Library/Python/2.5/site-packages/appscript-0.19.0-py2.5-macosx-10.5-i386.egg/appscript/reference.py”,第 513 行,调用 appscript.reference.CommandError: 命令失败:OSERROR:-10000 消息:Apple 事件处理程序失败。 命令: app(u'/System/Library/CoreServices/Finder.app').desktop_picture.set(mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']"))
我做了一些网络搜索但我找不到任何东西可以帮助我弄清楚 OSERROR -10000 的含义或如何解决该问题。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件名 = sys.argv[1]
代替
fileName = sys.argv[1:]
mactypes.File(u"/Users/Daniel/Pictures/['test.jpg']")
请参阅方括号和文件名周围有引号吗?
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?