def run_cmd(self, cmd):
""" run a mpd control command """
call = ["mpc"]
if self.host:
call.extend(["--host", self.host])
if self.port:
call.extend(["--port", self.port])
call.append(cmd)
proc = subprocess.Popen(call, stdout=subprocess.PIPE)
output, _ = proc.communicate()
try:
proc.wait(1)
except subprocess.TimeoutExpired:
raise Exception("mpc doesn't terminate!")
return output
评论列表
文章目录