[Reproducible-commits] [diffoscope] 02/04: Allow commands to be called with specified environment variables

Jérémy Bobbio lunar at moszumanska.debian.org
Sat Nov 14 13:45:30 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch master
in repository diffoscope.

commit 1538a64e0feb4a8507f2c99dbd2bc9d25e70cc67
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Sat Nov 14 13:57:35 2015 +0100

    Allow commands to be called with specified environment variables
    
    The Command class now has a new 'env' method to pass environment variables.
    The default implementation will return None which makes subprocess inherit the
    parent environment.
---
 diffoscope/comparators/utils.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index 2a0d209..767f01b 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -58,6 +58,7 @@ class Command(object, metaclass=ABCMeta):
         logger.debug('running %s', self.cmdline())
         self._process = subprocess.Popen(self.cmdline(),
                                          shell=False, close_fds=True,
+                                         env=self.env(),
                                          stdin=subprocess.PIPE,
                                          stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE)
@@ -82,6 +83,9 @@ class Command(object, metaclass=ABCMeta):
     def cmdline(self):
         raise NotImplemented
 
+    def env(self):
+        return None # inherit parent environment by default
+
     # Define only if needed. We take care of closing stdin.
     #def feed_stdin(self, stdin)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git



More information about the Reproducible-commits mailing list