Merge "utils.execute: make it possible to set the environment variables"
This commit is contained in:
commit
e881f0dabd
@ -12,6 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import copy
|
||||||
import hashlib
|
import hashlib
|
||||||
import locale
|
import locale
|
||||||
import math
|
import math
|
||||||
@ -76,7 +77,7 @@ def execute(*cmd, **kwargs):
|
|||||||
command = ' '.join(cmd)
|
command = ' '.join(cmd)
|
||||||
LOG.debug('Trying to execute command: %s', command)
|
LOG.debug('Trying to execute command: %s', command)
|
||||||
commands = [c.strip() for c in re.split(ur'\|', command)]
|
commands = [c.strip() for c in re.split(ur'\|', command)]
|
||||||
env = os.environ
|
env = kwargs.pop('env_variables', copy.deepcopy(os.environ))
|
||||||
env['PATH'] = '/bin:/usr/bin:/sbin:/usr/sbin'
|
env['PATH'] = '/bin:/usr/bin:/sbin:/usr/sbin'
|
||||||
env['LC_ALL'] = env['LANG'] = env['LANGUAGE'] = kwargs.pop('language', 'C')
|
env['LC_ALL'] = env['LANG'] = env['LANGUAGE'] = kwargs.pop('language', 'C')
|
||||||
attempts = kwargs.pop('attempts', 1)
|
attempts = kwargs.pop('attempts', 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user