2015-11-25 05:35:50 +08:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
|
|
|
Shared functionality used by `client` and `server` when dealing with
|
2015-12-01 06:31:13 +08:00
|
|
|
remote transmission
|
2015-11-25 05:35:50 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
# Future imports
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
# Python modules
|
|
|
|
import json
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import socket
|
|
|
|
import struct
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# LLDB modules
|
|
|
|
import use_lldb_suite
|
|
|
|
|
2015-12-01 06:31:13 +08:00
|
|
|
def generate_config(languages):
|
|
|
|
config = {"languages": languages}
|
2015-11-25 05:35:50 +08:00
|
|
|
return json.dumps(config)
|
|
|
|
|
2015-12-01 06:31:13 +08:00
|
|
|
def parse_config(json_reader):
|
|
|
|
json_data = json_reader.read()
|
|
|
|
options_dict = json.loads(json_data)
|
|
|
|
return options_dict
|
2015-12-01 06:31:24 +08:00
|
|
|
|
|
|
|
def serialize_response_status(status):
|
|
|
|
status = {"retcode": status[0], "output": status[1]}
|
|
|
|
return json.dumps(status)
|
|
|
|
|
|
|
|
def deserialize_response_status(json_reader):
|
|
|
|
json_data = json_reader.read()
|
|
|
|
response_dict = json.loads(json_data)
|
|
|
|
return (response_dict["retcode"], response_dict["output"])
|