aboutsummaryrefslogtreecommitdiff
path: root/lldb/scripts/swig_bot_lib/client.py
diff options
context:
space:
mode:
authorKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
committerKate Stone <katherine.stone@apple.com>2016-09-06 20:57:50 +0000
commitb9c1b51e45b845debb76d8658edabca70ca56079 (patch)
treedfcb5a13ef2b014202340f47036da383eaee74aa /lldb/scripts/swig_bot_lib/client.py
parentd5aa73376966339caad04013510626ec2e42c760 (diff)
downloadllvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz
llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.bz2
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
Diffstat (limited to 'lldb/scripts/swig_bot_lib/client.py')
-rw-r--r--lldb/scripts/swig_bot_lib/client.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/lldb/scripts/swig_bot_lib/client.py b/lldb/scripts/swig_bot_lib/client.py
index 9bf55b4..d9f0fb4 100644
--- a/lldb/scripts/swig_bot_lib/client.py
+++ b/lldb/scripts/swig_bot_lib/client.py
@@ -30,6 +30,7 @@ from . import remote
default_ip = "127.0.0.1"
default_port = 8537
+
def add_subparser_args(parser):
"""Returns options processed from the provided command line.
@@ -41,9 +42,11 @@ def add_subparser_args(parser):
# searches for a copy of swig located on the physical machine. If
# used with 1 argument, the argument is the path to a swig executable.
class FindLocalSwigAction(argparse.Action):
+
def __init__(self, option_strings, dest, **kwargs):
super(FindLocalSwigAction, self).__init__(
option_strings, dest, nargs='?', **kwargs)
+
def __call__(self, parser, namespace, values, option_string=None):
swig_exe = None
if values is None:
@@ -58,18 +61,20 @@ def add_subparser_args(parser):
# of the form `ip_address[:port]`. If the port is unspecified, the
# default port is used.
class RemoteIpAction(argparse.Action):
+
def __init__(self, option_strings, dest, **kwargs):
super(RemoteIpAction, self).__init__(
option_strings, dest, nargs='?', **kwargs)
+
def __call__(self, parser, namespace, values, option_string=None):
ip_port = None
if values is None:
ip_port = (default_ip, default_port)
else:
result = values.split(':')
- if len(result)==1:
+ if len(result) == 1:
ip_port = (result[0], default_port)
- elif len(result)==2:
+ elif len(result) == 2:
ip_port = (result[0], int(result[1]))
else:
raise ValueError("Invalid connection string")
@@ -108,6 +113,7 @@ def add_subparser_args(parser):
action="append",
help="Specifies the language to generate bindings for")
+
def finalize_subparser_options(options):
if options.languages is None:
options.languages = ['python']
@@ -118,6 +124,7 @@ def finalize_subparser_options(options):
return options
+
def establish_remote_connection(ip_port):
logging.debug("Creating socket...")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -127,6 +134,7 @@ def establish_remote_connection(ip_port):
logging.info("Connection established...")
return s
+
def transmit_request(connection, packed_input):
logging.info("Sending {} bytes of compressed data."
.format(len(packed_input)))
@@ -138,27 +146,28 @@ def transmit_request(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))
+ .format(options.target_dir))
os.makedirs(options.target_dir, exist_ok=True)
logging.info("Unpacking response archive into {}"
- .format(options.target_dir))
+ .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))
+ .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]))
+ .format(response[0]))
logging.error(response[1])
else:
logging.info("SWIG generation successful.")
@@ -167,6 +176,7 @@ def handle_response(options, connection, response):
finally:
os.unlink(response_file_path)
+
def run(options):
if options.remote is None:
logging.info("swig bot client using local swig installation at '{}'"
@@ -193,7 +203,8 @@ def run(options):
("scripts/Python", ".swig"),
("scripts/interface", ".i")]
zip_data = io.BytesIO()
- packed_input = local.pack_archive(zip_data, options.src_root, inputs)
+ packed_input = local.pack_archive(
+ zip_data, options.src_root, inputs)
logging.info("(null) -> config.json")
packed_input.writestr("config.json", config)
packed_input.close()
@@ -202,4 +213,4 @@ def run(options):
handle_response(options, connection, response)
finally:
if connection is not None:
- connection.close() \ No newline at end of file
+ connection.close()