291
291
Simplified access to some system commands.
294
def exec_command(self, command):
294
def exec_command(self, command, getOutput=True):
296
296
Execute a shell command
298
Set getOutput to False if the command does not exit and return immediately. Otherwise
299
AutoKey will not respond to any hotkeys/abbreviations etc until the process started
300
by the command exits.
298
Usage: C{system.exec_command(command)}
302
Usage: C{system.exec_command(command, getOutput=True)}
300
304
@param command: command to be executed (including any arguments) - e.g. "ls -l"
305
@param getOutput: whether to capture the (stdout) output of the command
301
306
@raises subprocess.CalledProcessError: if the command returns a non-zero exit code
303
p = subprocess.Popen(command, shell=True, bufsize=-1, stdout=subprocess.PIPE)
305
output = p.stdout.read()[:-1]
307
raise subprocess.CalledProcessError(retCode, output)
309
p = subprocess.Popen(command, shell=True, bufsize=-1, stdout=subprocess.PIPE)
311
output = p.stdout.read()[:-1]
313
raise subprocess.CalledProcessError(retCode, output)
317
subprocess.Popen(command, shell=True, bufsize=-1)
311
319
def create_file(self, fileName, contents=""):