From: Tomek Mrugalski Date: Thu, 9 Mar 2017 11:57:03 +0000 (+0100) Subject: [5137] Comments improved X-Git-Tag: trac5152_base~6^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5e03c7da8dc1b524bacb6c2001b2b97aee4d8d25;p=thirdparty%2Fkea.git [5137] Comments improved --- diff --git a/configure.ac b/configure.ac index a98db14b14..587a5c0500 100644 --- a/configure.ac +++ b/configure.ac @@ -470,6 +470,7 @@ AC_ARG_ENABLE(shell, [AC_HELP_STRING([--enable-shell], if test "x$enable_shell" != xno ; then # If kea-shell is enabled, we really need python. 2.7 or anything newer will do. +# We try to find 3.x first. If not found, we can do with 2.7. AM_PATH_PYTHON([3], [found="yes"], [found="no"]) if test "x$found" = xno ; then AM_PATH_PYTHON([2.7]) diff --git a/src/bin/shell/kea-shell.in b/src/bin/shell/kea-shell.in index d96fb70c70..e86c53c733 100644 --- a/src/bin/shell/kea-shell.in +++ b/src/bin/shell/kea-shell.in @@ -71,7 +71,7 @@ def shell_body(): print(VERSION) exit(0) - # Ok, now time to put the parameters parsed into the structure to be + # Ok, now it's time to put the parameters parsed into the structure to be # used by the connection. params = CARequest() params.command = cmd_args.command diff --git a/src/bin/shell/kea_connector2.py b/src/bin/shell/kea_connector2.py index 6f768881e8..47275ae3fc 100644 --- a/src/bin/shell/kea_connector2.py +++ b/src/bin/shell/kea_connector2.py @@ -13,7 +13,9 @@ import httplib from kea_conn import CAResponse # CARequest def send_to_control_agent(params): - """Establish HTTP connection first.""" + """ Sends a request to Control Agent, receives a response and returns it.""" + + # Establish HTTP connection first. conn = httplib.HTTPConnection(params.http_host, params.http_port) conn.connect() @@ -25,7 +27,7 @@ def send_to_control_agent(params): conn.putheader(k, params.headers[k]) conn.endheaders() - # Send the content + # Send the body (i.e. the actual content) conn.send(params.content) # Now get the response diff --git a/src/bin/shell/kea_connector3.py b/src/bin/shell/kea_connector3.py index 590ec39801..3ccb1aed1e 100644 --- a/src/bin/shell/kea_connector3.py +++ b/src/bin/shell/kea_connector3.py @@ -13,13 +13,18 @@ import urllib.request from kea_conn import CAResponse # CARequest def send_to_control_agent(params): - """Establish HTTP connection first.""" + """ Sends a request to Control Agent, receives a response and returns it.""" + + # First, create the URL url = "http://" + params.http_host + ":" url += str(params.http_port) + str(params.path) + # Now preprare the request (URL, headers and body) req = urllib.request.Request(url=url, data=str.encode(params.content), headers=params.headers) + + # Establish connection, send the request. resp = urllib.request.urlopen(req) # Now get the response details, put it in CAResponse and return it