And additionally, don't swallow error output from parsepkgbuild calls-
this helped debug the next issue with a patch to come.

Signed-off-by: Dan McGee <[email protected]>
---
 namcap.py |   13 +++++++------
 pacman.py |    7 ++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/namcap.py b/namcap.py
index 69787db..44440a9 100755
--- a/namcap.py
+++ b/namcap.py
@@ -103,7 +103,7 @@ def process_realpackage(package, modules):
        pkgtar = verify_package(package)
 
        if not pkgtar:
-               print("Error: " + package + " is empty or is not a valid 
package")
+               print("Error: %s is empty or is not a valid package" % package)
                return 1
 
        pkginfo = pacman.load(package)
@@ -167,11 +167,12 @@ def process_pkginfo(pkginfo, modules):
 
 def process_pkgbuild(package, modules):
        """Runs namcap checks over a PKGBUILD"""
-       # We might want to do some verifying in here... but really... isn't 
that what pacman.load is for?
+       # We might want to do some verifying in here... but really... isn't that
+       # what pacman.load is for?
        pkginfo = pacman.load(package)
 
        if pkginfo == None:
-               print("Error: " + package + " is not a valid PKGBUILD")
+               print("Error: %s is not a valid PKGBUILD" % package)
                return 1
 
        # apply global PKGBUILD rules
@@ -227,7 +228,7 @@ for i, k in optlist:
                        if j in modules:
                                active_modules[j] = modules[j]
                        else:
-                               print("Error: Rule '" + j + "' does not exist")
+                               print("Error: Rule '%s' does not exist" % j)
                                usage()
 
        # Used to exclude some rules from the check
@@ -238,7 +239,7 @@ for i, k in optlist:
                        if j in modules:
                                active_modules.pop(j)
                        else:
-                               print("Error: Rule '" + j + "' does not exist")
+                               print("Error: Rule '%s' does not exist" % j)
                                usage()
 
        if i in ('-i', '--info'):
@@ -266,7 +267,7 @@ if len(active_modules) == 0:
 # Go through each package, get the info, and apply the rules
 for package in packages:
        if not os.access(package, os.R_OK):
-               print("Error: Problem reading " + package)
+               print("Error: Problem reading %s" % package)
                usage()
 
        if os.path.isfile(package) and tarfile.is_tarfile(package):
diff --git a/pacman.py b/pacman.py
index eecc6c5..9473f6e 100644
--- a/pacman.py
+++ b/pacman.py
@@ -18,6 +18,7 @@
 # 
 
 import tarfile, os, re, subprocess
+import sys
 from Namcap.package import PacmanPackage
 
 pacmandb = '/var/lib/pacman/local/'
@@ -52,11 +53,15 @@ def load(package, root=None):
                if workingdir == '':
                        workingdir = None
                filename = os.path.basename(package)
-               process = subprocess.Popen(['parsepkgbuild',filename],
+               process = subprocess.Popen(['parsepkgbuild', filename],
                                stdout=subprocess.PIPE, stderr=subprocess.PIPE, 
cwd=workingdir)
                data = process.communicate()
                # this means parsepkgbuild returned an error, so we are not 
valid
                if process.returncode > 0:
+                       if data[0]:
+                               print("Error:", data[0].decode("utf-8", 
"ignore"))
+                       if data[1]:
+                               print("Error:", data[1].decode("utf-8", 
"ignore"), file=sys.stdout)
                        return None
                ret = PacmanPackage(db = data[0].decode('utf-8', 'ignore'))
 
-- 
1.7.4.1

Reply via email to