From c8d882ae2a75c732ef590ef425a3039b8b04403e Mon Sep 17 00:00:00 2001 From: Kris Giesing Date: Tue, 23 Dec 2014 13:02:32 -0800 Subject: [PATCH] Silence warnings about invalid clone.bundle files when quieted The invalid clone.bundle file warning is not typically user actionable, and can be confusing. So don't show it when -q flag is in effect. Change-Id: If9fef4085391acf54b63c75029ec0e161c38eb86 --- project.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/project.py b/project.py index cdce1e84..339f1a14 100644 --- a/project.py +++ b/project.py @@ -1973,7 +1973,7 @@ class Project(object): return False if os.path.exists(tmpPath): - if curlret == 0 and self._IsValidBundle(tmpPath): + if curlret == 0 and self._IsValidBundle(tmpPath, quiet): os.rename(tmpPath, dstPath) return True else: @@ -1982,13 +1982,14 @@ class Project(object): else: return False - def _IsValidBundle(self, path): + def _IsValidBundle(self, path, quiet): try: with open(path) as f: if f.read(16) == '# v2 git bundle\n': return True else: - print("Invalid clone.bundle file; ignoring.", file=sys.stderr) + if not quiet: + print("Invalid clone.bundle file; ignoring.", file=sys.stderr) return False except OSError: return False