MCPcopy Create free account
hub / github.com/apache/impala / exec_cmd

Function exec_cmd

bin/load-data.py:128–143  ·  view source on GitHub ↗

Run the given command in the shell returning whether the command succeeded. If 'error_msg' is set, log the error message on failure. If 'exit_on_error' is True, exit the program on failure. If 'out_file' is specified, log all output to that file.

(cmd, error_msg=None, exit_on_error=True, out_file=None)

Source from the content-addressed store, hash-verified

126 sys.exit(1)
127
128def exec_cmd(cmd, error_msg=None, exit_on_error=True, out_file=None):
129 """Run the given command in the shell returning whether the command
130 succeeded. If 'error_msg' is set, log the error message on failure.
131 If 'exit_on_error' is True, exit the program on failure.
132 If 'out_file' is specified, log all output to that file."""
133 success = True
134 if out_file:
135 with open(out_file, 'w') as f:
136 ret_val = subprocess.call(cmd, shell=True, stderr=f, stdout=f)
137 else:
138 ret_val = subprocess.call(cmd, shell=True)
139 if ret_val != 0:
140 if error_msg: LOG.info(error_msg)
141 if exit_on_error: sys.exit(ret_val)
142 success = False
143 return success
144
145def exec_hive_query_from_file_beeline(file_name):
146 if not os.path.exists(file_name):

Callers 5

run_dataset_preloadFunction · 0.70
exec_hadoop_fs_cmdFunction · 0.70

Calls 1

callMethod · 0.65

Tested by

no test coverage detected