[diffoscope] 03/03: comparators.fsimage: Tidy module.
Chris Lamb
chris at chris-lamb.co.uk
Sat Sep 9 12:16:56 CEST 2017
This is an automated email from the git hooks/post-receive script.
lamby pushed a commit to branch master
in repository diffoscope.
commit 23703113f0e4d798ec6183ff1d1a823e6e263a4b
Author: Chris Lamb <lamby at debian.org>
Date: Fri Sep 8 21:51:12 2017 +0100
comparators.fsimage: Tidy module.
Gbp-Dch: ignore
---
diffoscope/comparators/fsimage.py | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/diffoscope/comparators/fsimage.py b/diffoscope/comparators/fsimage.py
index 028d8c6..bf106db 100644
--- a/diffoscope/comparators/fsimage.py
+++ b/diffoscope/comparators/fsimage.py
@@ -39,20 +39,23 @@ class FsImageContainer(Archive):
if not guestfs:
return None
- self.g = guestfs.GuestFS (python_return_dict=True)
- if "LIBGUESTFS_CACHEDIR" in os.environ:
+ self.g = guestfs.GuestFS(python_return_dict=True)
+ try:
# force a check that LIBGUESTFS_CACHEDIR exists. otherwise guestfs
# will fall back to /var/tmp, which we don't want
- self.g.set_cachedir(os.getenv("LIBGUESTFS_CACHEDIR"))
- self.g.add_drive_opts (self.source.path, format="raw", readonly=1)
+ self.g.set_cachedir(os.environ['LIBGUESTFS_CACHEDIR'])
+ except KeyError:
+ pass
+ self.g.add_drive_opts(self.source.path, format='raw', readonly=1)
try:
self.g.launch()
except RuntimeError:
- logger.exception("guestfs can't be launched")
- logger.error("If memory is too tight for 512 MiB, try running with LIBGUESTFS_MEMSIZE=256 or lower.")
+ logger.exception("guestfs failed to launch")
+ logger.error("If memory is too tight for 512 MiB, try running "
+ "with LIBGUESTFS_MEMSIZE=256 or lower.")
return None
devices = self.g.list_devices()
- self.g.mount(devices[0], "/")
+ self.g.mount(devices[0], '/')
self.fs = self.g.list_filesystems()[devices[0]]
return self
@@ -68,10 +71,11 @@ class FsImageContainer(Archive):
def extract(self, member_name, dest_dir):
dest_path = os.path.join(dest_dir, member_name)
logger.debug('filesystem image extracting to %s', dest_path)
- self.g.tar_out("/", dest_path)
+ self.g.tar_out('/', dest_path)
return dest_path
+
class FsImageFile(File):
CONTAINER_CLASS = FsImageContainer
FILE_TYPE_RE = re.compile(r'^(Linux.*filesystem data|BTRFS Filesystem).*')
@@ -85,6 +89,8 @@ class FsImageFile(File):
if hasattr(other.as_container, 'fs'):
other_fs = other.as_container.fs
if my_fs != other_fs:
- differences.append(Difference.from_text(my_fs, other_fs, None, None, source="filesystem"))
+ differences.append(Difference.from_text(
+ my_fs, other_fs, None, None, source="filesystem",
+ ))
return differences
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list