@@ -233,8 +233,7 @@ class Atomic(object):
233233 return subprocess .check_call (cmd , stderr = DEVNULL )
234234 else :
235235 if self .command :
236- return subprocess .check_call (["/usr/bin/docker" , "exec" , "-t" , "-i" , self .name ] + self .command ,
237- stderr = DEVNULL )
236+ return subprocess .check_call (["/usr/bin/docker" , "exec" , "-t" , "-i" , self .name ] + self .command , stderr = DEVNULL )
238237 else :
239238 self .writeOut ("Container is running" )
240239
@@ -305,6 +304,13 @@ removes all containers based on an image.
305304 command += self .image
306305 return command
307306
307+ def _new_env (self ):
308+ env = os .environ
309+ env ["CONFDIR" ] = "/etc/%s" % self .name
310+ env ["LOGDIR" ] = "/var/log/%s" % self .name
311+ env ["DATADIR" ] = "/var/lib/%s" % self .name
312+ return env
313+
308314 def run (self ):
309315 self .inspect = self ._inspect_container ()
310316
@@ -344,16 +350,10 @@ removes all containers based on an image.
344350 self .writeOut (cmd )
345351
346352 if missing_RUN :
347- subprocess .check_call (cmd , env = {
348- "CONFDIR" : "/etc/%s" % self .name ,
349- "LOGDIR" : "/var/log/%s" % self .name ,
350- "DATADIR" :"/var/lib/%s" % self .name }, shell = True , stderr = DEVNULL , stdout = DEVNULL )
353+ subprocess .check_call (cmd , env = self ._new_env (), shell = True , stderr = DEVNULL , stdout = DEVNULL )
351354 return self ._start ()
352355
353- subprocess .check_call (cmd , env = {
354- "CONFDIR" : "/etc/%s" % self .name ,
355- "LOGDIR" : "/var/log/%s" % self .name ,
356- "DATADIR" :"/var/lib/%s" % self .name }, shell = True )
356+ subprocess .check_call (cmd , env = self ._new_env (), shell = True )
357357
358358
359359 def stop (self ):
@@ -363,11 +363,7 @@ removes all containers based on an image.
363363 cmd = self .gen_cmd (args )
364364 self .writeOut (cmd )
365365
366- subprocess .check_call (cmd , env = {
367- "CONFDIR" : "/etc/%s" % self .name ,
368- "LOGDIR" : "/var/log/%s" % self .name ,
369- "DATADIR" :"/var/lib/%s" % self .name }, shell = True )
370-
366+ subprocess .check_call (cmd , env = self ._new_env (), shell = True )
371367
372368 # Container exists
373369 if self .inspect ["State" ]["Running" ]:
@@ -417,10 +413,7 @@ removes all containers based on an image.
417413 if args :
418414 cmd = self .gen_cmd (args )
419415 self .writeOut (cmd )
420- subprocess .check_call (cmd , env = {
421- "CONFDIR" : "/etc/%s" % self .name ,
422- "LOGDIR" : "/var/log/%s" % self .name ,
423- "DATADIR" :"/var/lib/%s" % self .name }, shell = True )
416+ subprocess .check_call (cmd , env = self ._new_env (), shell = True )
424417 subprocess .check_call (["/usr/bin/docker" , "rmi" , self .image ])
425418
426419 def gen_cmd (self ,cargs ):
@@ -462,10 +455,7 @@ removes all containers based on an image.
462455 cmd = self .gen_cmd (args )
463456 self .writeOut (cmd )
464457
465- return (subprocess .check_call (cmd , env = {
466- "CONFDIR" : "/etc/%s" % self .name ,
467- "LOGDIR" : "/var/log/%s" % self .name ,
468- "DATADIR" :"/var/lib/%s" % self .name }, shell = True ))
458+ return subprocess .check_call (cmd , env = self ._new_env (), shell = True )
469459
470460 def help (self ):
471461 if os .path .exists ("/usr/bin/rpm-ostree" ):
0 commit comments