Python中的Pulseaudio和sudo

2024-10-03 17:26:01 发布

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

我正在运行一个在套接字上工作的脚本。。它需要sudo运行。。 然而, 在这个脚本中,我调用了另一个不需要作为sudo运行的脚本

代码如下:

import subprocess
import socket
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#s.settimeout(5.0)
host='192.168.1.148'
port=1022
s.bind((host, port))
s.listen(5)
while True:
    c, addr = s.accept()
    subprocess.call("python bluetooth2.py",shell=True)
    print 'got connection from',addr
    c.send('Thank you for connecting')
    #c.settimeout(5.0)
    c.recv(1022)
    c.close()

bluetooth2.py运行pulseaudio,由于某种原因,它以根用户身份运行,但不起作用。非常感谢任何帮助!在

下面是bluetooth2.py脚本的外观(调用pulseaudio的脚本)

^{pr2}$

Tags: 代码pyimport脚本truehostportsudo