You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2019/01/11 17:40:19 UTC

[trafficcontrol] branch master updated: Now that the Python client is a well-behaved package, genRoutesConfig.py can just require it (#3208)

This is an automated email from the ASF dual-hosted git repository.

mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new aec3bf2  Now that the Python client is a well-behaved package, genRoutesConfig.py can just require it (#3208)
aec3bf2 is described below

commit aec3bf2584f2c24d88039b3a58547f23e4df780a
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Fri Jan 11 10:40:14 2019 -0700

    Now that the Python client is a well-behaved package, genRoutesConfig.py can just require it (#3208)
---
 docs/source/tools/compare.rst                  |  1 +
 docs/source/tools/python_client.rst            |  2 ++
 traffic_ops/testing/compare/Dockerfile         |  4 ++--
 traffic_ops/testing/compare/README.md          |  3 +++
 traffic_ops/testing/compare/genConfigRoutes.py | 14 ++++----------
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/docs/source/tools/compare.rst b/docs/source/tools/compare.rst
index 9802cbc..7766bb4 100644
--- a/docs/source/tools/compare.rst
+++ b/docs/source/tools/compare.rst
@@ -74,6 +74,7 @@ These can be overridden by command line switches as described above. If a userna
 
 genConfigRoutes.py
 ------------------
+.. note:: This script uses the :ref:`py-client`, and so that must be installed to use it.
 
 ``usage: genConfigRoutes.py [-h] [--refURL REFURL] [--testURL TESTURL]``
                           ``[--refUser REFUSER] [--refPasswd REFPASSWD]``
diff --git a/docs/source/tools/python_client.rst b/docs/source/tools/python_client.rst
index 2135ad2..3356116 100644
--- a/docs/source/tools/python_client.rst
+++ b/docs/source/tools/python_client.rst
@@ -13,6 +13,8 @@
 .. limitations under the License.
 ..
 
+.. _py-client:
+
 *****************************
 Apache-TrafficControl Package
 *****************************
diff --git a/traffic_ops/testing/compare/Dockerfile b/traffic_ops/testing/compare/Dockerfile
index 4a93efa..215417d 100644
--- a/traffic_ops/testing/compare/Dockerfile
+++ b/traffic_ops/testing/compare/Dockerfile
@@ -31,9 +31,9 @@ RUN mkdir -p /go/src/github.com/apache/trafficcontrol/traffic_control/clients/py
 
 RUN apk update
 RUN apk add python3 git
-RUN python3 -m ensurepip && python3 -m pip install --upgrade pip && python3 -m pip install requests munch
-
 ADD traffic_control/clients/python /go/src/github.com/apache/trafficcontrol/traffic_control/clients/python/
+RUN python3 -m ensurepip && python3 -m pip install --upgrade pip && python3 -m pip install /go/src/github.com/apache/trafficcontrol/traffic_control/clients/python/
+
 ADD lib /go/src/github.com/apache/trafficcontrol/lib
 ADD vendor /go/src/github.com/apache/trafficcontrol/vendor
 ADD traffic_ops/vendor/github.com/kelseyhightower /go/src/github.com/apache/trafficcontrol/traffic_ops/vendor/github.com/kelseyhightower
diff --git a/traffic_ops/testing/compare/README.md b/traffic_ops/testing/compare/README.md
index a91a25b..4fc3a51 100644
--- a/traffic_ops/testing/compare/README.md
+++ b/traffic_ops/testing/compare/README.md
@@ -69,6 +69,9 @@ These can be overridden by command line switches as described above. If a userna
 
 ### genConfigRoutes.py
 
+!!! note
+  This script requires the Apache-TrafficControl client package to be installed. See the [client README](../../../traffic_control/clients/python/README.rst) for installation instructions.
+
 usage: genConfigRoutes.py [-h] [--refURL REFURL] [--testURL TESTURL]
                           [--refUser REFUSER] [--refPasswd REFPASSWD]
                           [--testUser TESTUSER] [--testPasswd TESTPASSWD] [-k]
diff --git a/traffic_ops/testing/compare/genConfigRoutes.py b/traffic_ops/testing/compare/genConfigRoutes.py
index 7317ba4..0980ac0 100755
--- a/traffic_ops/testing/compare/genConfigRoutes.py
+++ b/traffic_ops/testing/compare/genConfigRoutes.py
@@ -19,6 +19,8 @@
 """
 This script is meant to generate a list of Traffic Ops API routes that point to configuration files
 for cache servers. It verifies that servers of the same name both exist and have the same routes.
+
+Note that the Python Apache-TrafficControl client package must be installed to use this script.
 """
 
 import argparse
@@ -29,19 +31,11 @@ import time
 import typing
 import sys
 
-random.seed(time.time())
-
-#: The repository root directory
-ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", ".."))
-
-#: An absolute path to the Traffic Ops python packages (This assumes that the script is run from
-#: within the repository's normal directory structure)
-TO_LIBS_PATH = os.path.join(ROOT, "traffic_control", "clients", "python") 
-
-sys.path.insert(0, TO_LIBS_PATH)
 from trafficops.tosession import TOSession
 from trafficops.restapi import LoginError, OperationError, InvalidJSONError
 
+random.seed(time.time())
+
 #: A format specifier for logging output. Propagates to all imported modules.
 LOG_FMT = "%(levelname)s: %(asctime)s line %(lineno)d in %(module)s.%(funcName)s: %(message)s"