- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- res = p.communicate()[0] # get only stdout
- if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE) as p:
+ res = p.communicate()[0] # get only stdout
+ if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")