[Reproducible-commits] [debbindiff] 02/02: Fallback on binary comparison when external tools fail
Jérémy Bobbio
lunar at moszumanska.debian.org
Fri Jan 9 20:42:34 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository debbindiff.
commit e3b2041173f3d373321b2ef57633b7fde7ceff2c
Author: Jérémy Bobbio <lunar at debian.org>
Date: Fri Jan 9 20:41:35 2015 +0000
Fallback on binary comparison when external tools fail
Closes: #764140
---
debbindiff/comparators/utils.py | 28 +++++++++++++++++++---------
debbindiff/presenters/html.py | 2 +-
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/debbindiff/comparators/utils.py b/debbindiff/comparators/utils.py
index 5a729fc..1737655 100644
--- a/debbindiff/comparators/utils.py
+++ b/debbindiff/comparators/utils.py
@@ -19,6 +19,7 @@
from contextlib import contextmanager
import hashlib
+import re
import shutil
import subprocess
import tempfile
@@ -45,20 +46,28 @@ def are_same_binaries(path1, path2):
# decorator that will create a fallback on binary diff if no differences
-# are detected
+# are detected or if an external tool fails
def binary_fallback(original_function):
def with_fallback(path1, path2, source=None):
if are_same_binaries(path1, path2):
return []
- inside_differences = original_function(path1, path2, source)
- # no differences detected inside? let's at least do a binary diff
- if len(inside_differences) == 0:
+ try:
+ inside_differences = original_function(path1, path2, source)
+ # no differences detected inside? let's at least do a binary diff
+ if len(inside_differences) == 0:
+ difference = compare_binary_files(path1, path2, source=source)[0]
+ difference.comment = \
+ "No differences found inside, yet data differs"
+ else:
+ difference = Difference(None, None, path1, path2, source=source)
+ difference.add_details(inside_differences)
+ except subprocess.CalledProcessError as e:
difference = compare_binary_files(path1, path2, source=source)[0]
+ output = re.sub(r'^', ' ', e.output, flags=re.MULTILINE)
+ cmd = ' '.join(e.cmd)
difference.comment = \
- "No differences found inside, yet data differs"
- else:
- difference = Difference(None, None, path1, path2, source=source)
- difference.add_details(inside_differences)
+ "Command `%s` exited with %d. Output:\n%s" \
+ % (cmd, e.returncode, output)
return [difference]
return with_fallback
@@ -71,4 +80,5 @@ def make_temp_directory():
def get_ar_content(path):
- return subprocess.check_output(['ar', 'tv', path], shell=False)
+ return subprocess.check_output(
+ ['ar', 'tv', path], stderr=subprocess.STDOUT, shell=False)
diff --git a/debbindiff/presenters/html.py b/debbindiff/presenters/html.py
index ae47d1d..f8fddf1 100644
--- a/debbindiff/presenters/html.py
+++ b/debbindiff/presenters/html.py
@@ -163,7 +163,7 @@ def output_difference(difference, print_func):
% escape(difference.source2))
if difference.comment:
print_func("<div class='comment'>%s</div>"
- % escape(difference.comment))
+ % escape(difference.comment).replace('\n', '<br />'))
if difference.lines1 and difference.lines2:
print_func(create_diff(difference.lines1, difference.lines2))
for detail in difference.details:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/debbindiff.git
More information about the Reproducible-commits
mailing list