我已经改变了我的Java应用程序,以不同的方式与iTunes交互,但仍然使用applescript,但是虽然它对我有用,但它似乎给我的很多用户造成了问题,一个用户用户报告此错误多次出现
10/20/13 12:37:44.553 PM iTunes[74256]: AppleEvents/sandbox: Returning errAEPrivilegeError/-10004 and denying dispatch of event rdwr/writ from process 'Jaikoz'/0x0-0x413413, pid=19717, because it is not entitled to send an AppleEvent to this process.但我不明白为什么他会得到这个错误而我不是,有什么想法吗?
AppleScript的
tell application "iTunes" set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt") set fileref to open for access (thePath) with write permission set eof fileref to 0 set mainLibrary to library playlist 1 repeat with nexttrack in (get every track of mainLibrary) if (class of nexttrack is file track) then try set trackname to name of nexttrack set loc to location of nexttrack set locpath to POSIX path of loc set persistid to persistent ID of nexttrack set nextline to trackname & "::" & locpath & "::" & persistid write nextline & "\n" as "utf8" to fileref starting at eof end try end if end repeat end tell return ""更新我也意识到我已经改变了我与iTunes交谈的方式,我曾经使用过
osascript -a with Runtime.getRuntime().exec()但现在呢
ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("AppleScript");这可能是问题吗?
更新2这是一个纯Applescript问题,因为当我从Applescript编辑器运行时发生类似的错误
25/10/2013 10:39:39.816 iTunes[3366]: AppleEvents/sandbox: Returning errAEPrivilegeError /-10004 and denying dispatch of event rdwr/writ from process 'AppleScript Editor'/0x0-0x24d24d, pid=12717, because it is not entitled to send an AppleEvent to this process.问题不是没有访问iTunes,而是iTunes每次写入文件时都会抱怨(或打开/关闭文件) - 为什么会这样?
I've changed my Java application to interact with iTunes in a different way but still using applescript, but although it is working for me it seems to be causing problems for alot of my users, one user user has reported this error appearing numerous times
10/20/13 12:37:44.553 PM iTunes[74256]: AppleEvents/sandbox: Returning errAEPrivilegeError/-10004 and denying dispatch of event rdwr/writ from process 'Jaikoz'/0x0-0x413413, pid=19717, because it is not entitled to send an AppleEvent to this process.but I don't understand why he would be getting this error and I am not, any ideas ?
Applescript
tell application "iTunes" set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt") set fileref to open for access (thePath) with write permission set eof fileref to 0 set mainLibrary to library playlist 1 repeat with nexttrack in (get every track of mainLibrary) if (class of nexttrack is file track) then try set trackname to name of nexttrack set loc to location of nexttrack set locpath to POSIX path of loc set persistid to persistent ID of nexttrack set nextline to trackname & "::" & locpath & "::" & persistid write nextline & "\n" as "utf8" to fileref starting at eof end try end if end repeat end tell return ""Update I also just realized that I have changed the way I talk to iTunes, I used to use
osascript -a with Runtime.getRuntime().exec()but now do
ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName("AppleScript");could that be the issue ?
Update 2 This is a pure Applescript problem because a similar error occurs when i run from Applescript editor
25/10/2013 10:39:39.816 iTunes[3366]: AppleEvents/sandbox: Returning errAEPrivilegeError /-10004 and denying dispatch of event rdwr/writ from process 'AppleScript Editor'/0x0-0x24d24d, pid=12717, because it is not entitled to send an AppleEvent to this process.The problem is not after all not having access to iTunes, rather iTunes complains every time it writes to the file (or open/closes the file) - why would that be ?
最满意答案
问题原来是Applescript本身,它与Java无关或我是如何调用Applescript的,错误是关于iTunes无法写入文件系统上的文件的错误,修改如下修复了问题
set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt") set fileref to open for access (thePath) with write permission set eof fileref to 0 tell application "iTunes" set mainLibrary to library playlist 1 repeat with nexttrack in (get every track of mainLibrary) if (class of nexttrack is file track) then try set trackname to name of nexttrack set loc to location of nexttrack set locpath to POSIX path of loc set persistid to persistent ID of nexttrack set nextline to trackname & "::" & locpath & "::" & persistid tell current application to write nextline & "\n" as «class utf8» to fileref end try end if end repeat end tell close access fileref return ""The issue turned out to be the Applescript itself, it had nothing to do with Java or how I was calling Applescript, the error was an error about iTunes not being able to write to files on the filesystem, modifying as follows fixed the problem
set thePath to (POSIX file "/tmp/jaikoz_itunes_model.txt") set fileref to open for access (thePath) with write permission set eof fileref to 0 tell application "iTunes" set mainLibrary to library playlist 1 repeat with nexttrack in (get every track of mainLibrary) if (class of nexttrack is file track) then try set trackname to name of nexttrack set loc to location of nexttrack set locpath to POSIX path of loc set persistid to persistent ID of nexttrack set nextline to trackname & "::" & locpath & "::" & persistid tell current application to write nextline & "\n" as «class utf8» to fileref end try end if end repeat end tell close access fileref return ""更多推荐
发布评论