mirror of
https://github.com/apache/impala.git
synced 2025-12-19 18:12:08 -05:00
IMPALA-9157: Make helper function exec_local_command python 2.6 compatible
Change-Id: I928a4df9dc883e8e801a42ead14ec7875169d4ae Reviewed-on: http://gerrit.cloudera.org:8080/14788 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
4c09975c14
commit
db69fe87a8
@@ -16,22 +16,35 @@
|
||||
# under the License.
|
||||
|
||||
import fnmatch
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
logging.basicConfig()
|
||||
LOG = logging.getLogger('impala_lib_python_helpers')
|
||||
|
||||
|
||||
def exec_local_command(cmd):
|
||||
"""
|
||||
Executes a command for the local bash shell and return stdout as a string.
|
||||
|
||||
Raise CalledProcessError in case of non-zero return code.
|
||||
|
||||
Args:
|
||||
cmd: command as a string
|
||||
|
||||
Return:
|
||||
STDOUT
|
||||
"""
|
||||
return subprocess.check_output(cmd.split())
|
||||
proc = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output, error = proc.communicate()
|
||||
retcode = proc.poll()
|
||||
if retcode:
|
||||
LOG.error("{0} returned status {1}: {2}".format(cmd, retcode, error))
|
||||
raise subprocess.CalledProcessError()
|
||||
else:
|
||||
return output
|
||||
|
||||
|
||||
def find_all_files(fname_pattern, base_dir=os.getenv('IMPALA_HOME', '.')):
|
||||
|
||||
Reference in New Issue
Block a user