29 logger = logging.getLogger(
"Shell")
34 self.
env=os.environ.copy()
46 logger.debug(
"Appending '%s' to '%s'" % (value, key))
47 if key
not in list(self.
env.keys()):
50 self.
env[key] +=
":"+value
52 logger.debug(
"Prepending '%s' to '%s'" % (value, key))
53 if key
not in list(self.
env.keys()):
56 self.
env[key] = value+
":"+self.
env[key]
58 if isinstance(cmd, list):
65 if isinstance(cmd, list):
71 def cd(self, dirname):
75 self.
cwd = os.getcwd()
81 subprocess.check_call(cmd, env=self.
env,stderr=subprocess.STDOUT, shell=
True)
82 logger.debug(
"%s returned" % cmd)
92 out = subprocess.check_output(cmd, env=self.
env, stderr=subprocess.STDOUT, shell=
True)
93 except subprocess.CalledProcessError
as cpe:
95 if (len(out.strip()) > 0):
97 logger.debug(
"%s returned" % cmd)
101 out = subprocess.check_output(cmd, env=self.
env, stderr=subprocess.STDOUT, shell=
True).decode(
'utf-8')
102 if (len(out.strip()) > 0):
104 logger.debug(
"%s returned" % cmd)