def pquery(command, stdin=None, **kwargs):
if very_verbose:
info('Query "'+' '.join(command)+'" in '+getcwd())
try:
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs)
except OSError as e:
if e[0] == errno.ENOENT:
error(
"Could not execute \"%s\".\n"
"Please verify that it's installed and accessible from your current path by executing \"%s\".\n" % (command[0], command[0]), e[0])
else:
raise e
stdout, _ = proc.communicate(stdin)
if very_verbose:
log(str(stdout).strip()+"\n")
if proc.returncode != 0:
raise ProcessException(proc.returncode, command[0], ' '.join(command), getcwd())
return stdout
评论列表
文章目录