尝试从作为服务启动的Python脚本开始程序

2024-05-15 23:26:33 发布

您现在位置:Python中文网/ 问答频道 /正文

以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目录中。 服务正常启动,但: 在这个脚本中,我尝试启动程序(带有参数-playlist的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.

帮我理解。。。你知道吗


Tags: thekey脚本comforstringversionusers