diff options
Diffstat (limited to 'lldb/scripts/swig_bot_lib/client.py')
-rw-r--r-- | lldb/scripts/swig_bot_lib/client.py | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/lldb/scripts/swig_bot_lib/client.py b/lldb/scripts/swig_bot_lib/client.py index 80a3114ddb8..74c9f163388 100644 --- a/lldb/scripts/swig_bot_lib/client.py +++ b/lldb/scripts/swig_bot_lib/client.py @@ -133,7 +133,7 @@ def establish_remote_connection(ip_port): logging.info("Connection established...") return s -def transmit_data(connection, packed_input): +def transmit_request(connection, packed_input): logging.info("Sending {} bytes of compressed data." .format(len(packed_input))) connection.sendall(struct.pack("!I", len(packed_input))) @@ -144,6 +144,35 @@ def transmit_data(connection, packed_input): response = sockutil.recvall(connection, response_len) return response +def handle_response(options, connection, response): + logging.debug("Received {} byte response.".format(len(response))) + logging.debug("Creating output directory {}" + .format(options.target_dir)) + os.makedirs(options.target_dir, exist_ok=True) + + logging.info("Unpacking response archive into {}" + .format(options.target_dir)) + local.unpack_archive(options.target_dir, response) + response_file_path = os.path.normpath( + os.path.join(options.target_dir, "swig_output.json")) + if not os.path.isfile(response_file_path): + logging.error("Response file '{}' does not exist." + .format(response_file_path)) + return + try: + response = remote.deserialize_response_status( + io.open(response_file_path)) + if response[0] != 0: + logging.error("An error occurred during generation. Status={}" + .format(response[0])) + logging.error(response[1]) + else: + logging.info("SWIG generation successful.") + if len(response[1]) > 0: + logging.info(response[1]) + finally: + os.unlink(response_file_path) + def run(args): options = process_args(args) @@ -176,10 +205,9 @@ def run(args): logging.info("(null) -> config.json") packed_input.writestr("config.json", config) packed_input.close() - connection = establish_remote_connection(options.remote) - response = transmit_data(connection, zip_data.getvalue()) - logging.debug("Received {} byte response.".format(len(response))) + response = transmit_request(connection, zip_data.getvalue()) + handle_response(options, connection, response) finally: if connection is not None: connection.close()
\ No newline at end of file |