Commit 5e03c7da authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[5137] Comments improved

parent f0494b21
......@@ -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])
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment