尝试从 python 脚本启动程序作为服务启动

try start program from python script started as service

创建了一个 python 脚本形式的服务,其中应通过命令启动具有特定播放列表的 VLC。 服务列表:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs$
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.bioxakep.biobot.plist</string>
    <key>Program</key>
    <string>/Users/BioMac/Documents/Scripts/newHome.py</string>
    <key>KeepAlive</key>
    <true/>
    <key>StandardOutPath</key>
    <string>/tmp/biobot.out</string>
    <key>StandardErrorPath</key>
    <string>/tmp/biobot.err</string>
</dict>
</plist>

原则上缺少~/Library/LaunchAgents目录,所以服务位于 /Library/LaunchAgents目录。 服务正常启动,但是: 在此脚本中,我尝试启动程序(带有参数 - 播放列表的 VLC):

os.system('open -a vlc /Users/BioMac/Desktop/Radio.m3u')

VLC 尝试启动并挂起,但在日志视图中出现错误:

LSOpenURLsWithRole () failed for the application /Aplplications/VLC.app with error -600 for the file /Users/BioMac/Desktop/Radio.m3u.
LSOpenURLsWithRole () failed for the application /Aplplications/VLC.app with error -10810 for the file /Users/BioMac/Desktop/Radio.m3u.

帮我理解...

我认为您应该使用 Console.app(使用 Ctrl+Space 显示它)来发现有关挂起的更多信息。

可在此处找到有关代码 -10810 的更多信息:http://www.thexlab.com/faqs/error-10810.html

可在此处找到有关代码 -600 的更多信息: https://discussions.apple.com/thread/1611175