Zachary Turner | 9befc01 | 2015-11-24 21:35:50 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | """ |
| 4 | Shared functionality used by `client` and `server` when dealing with |
Zachary Turner | 24a95f8 | 2015-11-30 22:31:13 +0000 | [diff] [blame] | 5 | remote transmission |
Zachary Turner | 9befc01 | 2015-11-24 21:35:50 +0000 | [diff] [blame] | 6 | """ |
| 7 | |
| 8 | # Future imports |
| 9 | from __future__ import absolute_import |
| 10 | from __future__ import print_function |
| 11 | |
| 12 | # Python modules |
| 13 | import json |
| 14 | import logging |
| 15 | import os |
| 16 | import socket |
| 17 | import struct |
| 18 | import sys |
| 19 | |
| 20 | # LLDB modules |
| 21 | import use_lldb_suite |
| 22 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 23 | |
Zachary Turner | 24a95f8 | 2015-11-30 22:31:13 +0000 | [diff] [blame] | 24 | def generate_config(languages): |
| 25 | config = {"languages": languages} |
Zachary Turner | 9befc01 | 2015-11-24 21:35:50 +0000 | [diff] [blame] | 26 | return json.dumps(config) |
| 27 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 28 | |
Zachary Turner | 24a95f8 | 2015-11-30 22:31:13 +0000 | [diff] [blame] | 29 | def parse_config(json_reader): |
| 30 | json_data = json_reader.read() |
| 31 | options_dict = json.loads(json_data) |
| 32 | return options_dict |
Zachary Turner | 6f12d33 | 2015-11-30 22:31:24 +0000 | [diff] [blame] | 33 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 34 | |
Zachary Turner | 6f12d33 | 2015-11-30 22:31:24 +0000 | [diff] [blame] | 35 | def serialize_response_status(status): |
| 36 | status = {"retcode": status[0], "output": status[1]} |
| 37 | return json.dumps(status) |
| 38 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 39 | |
Zachary Turner | 6f12d33 | 2015-11-30 22:31:24 +0000 | [diff] [blame] | 40 | def deserialize_response_status(json_reader): |
| 41 | json_data = json_reader.read() |
| 42 | response_dict = json.loads(json_data) |
| 43 | return (response_dict["retcode"], response_dict["output"]) |