Commits

Anonymous committed 5661ee6

Fixed OSError, if libconfig or pkg-config command do not exist.

  • Participants
  • Parent commits 152780a
  • Branches pgreloaded

Comments (0)

Files changed (2)

config/libconfig.py

     msys_obj = None
 
 def run_command (cmd):
-    if msys.is_msys():
-        return msys_obj.run_shell_command (cmd)
-    else:
-        p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                             stderr=subprocess.PIPE)
-        output = p.communicate()[0]
-        if helpers.getversion()[0] >= 3:
-            output = str (output, "ascii")
-        return p.returncode, output
+    try:
+        if msys.is_msys():
+            return msys_obj.run_shell_command (cmd)
+        else:
+            p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+            output = p.communicate()[0]
+            if helpers.getversion()[0] >= 3:
+                output = str (output, "ascii")
+            return p.returncode, output
+    except OSError:
+        return -1, None
 
 def exec_config(libconfig, flags):
     cmd = [libconfig, flags]

config/pkgconfig.py

     msys_obj = None
 
 def run_command (cmd):
-    if msys.is_msys():
-        return msys_obj.run_shell_command (cmd)
-    else:
-        p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                             stderr=subprocess.PIPE)
-        output = p.communicate()[0]
-        if helpers.getversion()[0] >= 3:
-            output = str (output, "ascii")
-        return p.returncode, output
+    try:
+        if msys.is_msys():
+            return msys_obj.run_shell_command (cmd)
+        else:
+            p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
+                                 stderr=subprocess.PIPE)
+            output = p.communicate()[0]
+            if helpers.getversion()[0] >= 3:
+                output = str (output, "ascii")
+            return p.returncode, output
+    except OSError:
+        return -1, None
 
 def exec_pkgconfig (package, flags, repl=None):
     cmd = ["pkg-config", flags, package]
 def has_pkgconfig ():
     cmd = ["pkg-config", "--version"]
     return run_command (cmd)[0] == 0
-    return True