1 ##############################################################################
2 # Copyright (c) 2016 Juan Qiu
3 # juan_ qiu@tongji.edu.cn
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
13 LOG = logging.getLogger(__name__)
16 def buildshellparams(param, remote=True):
19 result = '/bin/bash -s' if remote else ''
20 for key in param.keys():
21 values.append(param[key])
27 def execute_shell_command(command):
28 """execute shell script with error handling"""
32 LOG.debug("the command is: %s", command)
33 output = subprocess.check_output(command, shell=True)
36 output = traceback.format_exc()
37 LOG.error("exec command '%s' error:\n ", command)
38 LOG.error(traceback.format_exc())
40 return exitcode, output