summaryrefslogtreecommitdiff
path: root/morphlib/util.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-03-11 14:10:53 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-03-11 14:10:53 +0000
commit0ad15d6122bc62a2964bc0fd9b23fa2318321304 (patch)
treec49d86487c7b2d9b044e39474cbc5dc9e32723a4 /morphlib/util.py
parentab90f3561ce43dba089686c743ecf0c4d6f33d31 (diff)
parent177405915072deebff194e5ed20182a641416155 (diff)
downloadmorph-0ad15d6122bc62a2964bc0fd9b23fa2318321304.tar.gz
Merge remote-tracking branch 'origin/baserock/richardholland/environment-logging' into staging
Added a "pragma: no cover" to make the test suite pass.
Diffstat (limited to 'morphlib/util.py')
-rw-r--r--morphlib/util.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/morphlib/util.py b/morphlib/util.py
index c832a141..b4e06092 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -16,6 +16,7 @@
import re
import morphlib
+import logging
'''Utility functions for morph.'''
@@ -170,6 +171,22 @@ def new_repo_caches(app): # pragma: no cover
return lrc, rrc
+def log_dict_diff(cur, pre): # pragma: no cover
+ '''Log the differences between two dicts to debug log'''
+ dictA = cur
+ dictB = pre
+ for key in dictA.keys():
+ if key not in dictB:
+ logging.debug("New environment: %s = %s" % (key, dictA[key]))
+ elif dictA[key] != dictB[key]:
+ logging.debug(
+ "Environment changed: %(key)s = %(valA)s to %(key)s = %(valB)s"
+ % {"key": key, "valA": dictA[key], "valB": dictB[key]})
+ for key in dictB.keys():
+ if key not in dictA:
+ logging.debug("Environment removed: %s = %s" % (key, dictB[key]))
+
+
# This acquired from rdiff-backup which is GPLv2+ and a patch from 2011
# which has not yet been merged, combined with a tad of tidying from us.
def copyfileobj(inputfp, outputfp, blocksize=1024*1024): # pragma: no cover