Use subprocess.check_output
[auto-debuild.git] / auto_debuild.py
index 410d8489cd3118b5d5fd2e4cd0f79db5c06e43a9..11935ef4b1fe27254e77f961e303d8906f13cc38 100755 (executable)
@@ -177,10 +177,8 @@ def commandInBuildEnv(config, command):
 
 def getArchitecture(config):
        cmd = commandInBuildEnv(config, ['dpkg-architecture', '-qDEB_HOST_ARCH'])
-       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")
-       return res[0:len(res)-1] # chop of the \n at the end
+       output = subprocess.check_output(cmd)
+       return output.decode('utf-8').strip('\n') # chop of the \n at the end
 
 def writeDependency(f, name, list):
        if len(list):