0

我试图通过 kodi 运行一个 python 脚本,它打开一个到我的远程 Raspberry Pi 的 SSH 连接并运行一个 .sh 脚本。然而,Kodi 似乎无法很好地解决路径。

我从 termux 运行了同样的 python 脚本,它运行良好。不确定我是否必须使用 xbmc.translatepath。那里有任何科迪传奇知道我做错了什么吗?

#!/usr/bin/python2
import subprocess

subprocess.call('ssh pi@192.168.1.14 -p 22 -i /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.hyperion/.ssh/id_rsa bash "/home/pi/hyperion_on.sh"', shell=True)

请参阅下面的错误。

ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script 
returned the following error<--- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.OSError'>
Error Contents: [Errno 2] No such file or directory
Traceback (most recent call last):
File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.hyperion/hyperion_on.py", line 17, in <module>
subprocess.call('ssh pi@192.168.1.14 -p 22 -i /storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/script.hyperion/.ssh/id_rsa bash "/home/pi/hyperion_on.sh"', shell=True)
File "/home/jenkins/workspace/Android-ARM/tools/depends/xbmc-depends/arm-linux-    androideabi-android-21/lib/python2.7/subprocess.py", line 523, in call
File "/home/jenkins/workspace/Android-ARM/tools/depends/xbmc-depends/arm-linux-    androideabi-android-21/lib/python2.7/subprocess.py", line 711, in __init__
File "/home/jenkins/workspace/Android-ARM/tools/depends/xbmc-depends/arm-linux-    androideabi-android-21/lib/python2.7/subprocess.py", line 1343, in _execute_child
OSError: [Errno 2] No such file or directory
-->End of Python script error report<--
4

1 回答 1

0

Android 上的 Termux 是它自己的独立环境。其中的命令不是 Android 核心系统的一部分,也不是 Kodi 默认知道的任何路径。如果你运行which ssh,你会看到它在某个地方,例如/data/data/com.termux/files/usr/bin/ssh. 不过,我不确定 Kodi 是否能够使用它。查看以下内容,它可能会有所帮助:

https://github.com/termux/termux-app/issues/77

于 2019-01-25T02:42:33.033 回答