spongeblink Posted June 8 Posted June 8 I have tried os.system and subprocess.Popen() (with the following code), and neither of them worked #!/usr/bin/python3 import os import shutil import sys import subprocess from subprocess import PIPE import shlex from Alfred3 import Tools query = Tools.getArgv(1) adr, switch = tuple(query.split(";")) blueutil = shutil.which('blueutil') if blueutil: if switch == "disconnected": Tools.log("Connect") cmd = f'{blueutil} --connect {adr}' else: Tools.log("Disconnect") cmd = f'{blueutil} --disconnect {adr}' Tools.log(cmd) args = shlex.split(cmd) Tools.log(str(args)) process = subprocess.Popen(args, stdout=PIPE, stderr=PIPE, shell=True) stdout, stderr = process.communicate() Tools.log(stdout.decode(encoding='utf-8')) Tools.log(stderr.decode(encoding='utf-8')) Tools.log(str(process.returncode)) Tools.log("Finished")
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now