aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Vinciguerra <pvinci@vinciconsulting.com>2019-03-17 17:34:46 -0700
committerOle Trøan <otroan@employees.org>2019-05-15 06:56:53 +0000
commit19542299d3f4095acda802b73b8a71a2f208cdf2 (patch)
tree404be7d2ac46252ad41e944813d82c485f591e65 /src
parent93248789fb892c3a0f37ec790293344efd860081 (diff)
vpp_papi: remove dependency on environment var. VPP_API_DIR.
Change-Id: I9e3af8674e8aae27079fd03f6286f165d777814f Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/python/vpp_papi/vpp_papi.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_papi.py b/src/vpp-api/python/vpp_papi/vpp_papi.py
index 9849d2e487c..8dcd63a0c55 100644
--- a/src/vpp-api/python/vpp_papi/vpp_papi.py
+++ b/src/vpp-api/python/vpp_papi/vpp_papi.py
@@ -121,7 +121,7 @@ class VPPValueError(ValueError):
pass
-class VPP(object):
+class VPPApiClient(object):
"""VPP interface.
This class provides the APIs to VPP. The APIs are loaded
@@ -133,6 +133,7 @@ class VPP(object):
provides a means to register a callback function to receive
these messages in a background thread.
"""
+ apidir = None
VPPApiError = VPPApiError
VPPRuntimeError = VPPRuntimeError
VPPValueError = VPPValueError
@@ -211,6 +212,9 @@ class VPP(object):
loglevel, if supplied, is the log level this logger is set
to report at (from the loglevels in the logging module).
"""
+ if apifiles is None and self.__class__.apidir is None:
+ raise ValueError("Either apifiles or apidir must be specified.")
+
if logger is None:
logger = logging.getLogger(__name__)
if loglevel is not None:
@@ -288,10 +292,7 @@ class VPP(object):
:returns: A single directory name, or None if no such directory
could be found.
"""
- dirs = []
-
- if 'VPP_API_DIR' in os.environ:
- dirs.append(os.environ['VPP_API_DIR'])
+ dirs = [cls.apidir]
# perhaps we're in the 'src/scripts' or 'src/vpp-api/python' dir;
# in which case, plot a course to likely places in the src tree
@@ -353,7 +354,7 @@ class VPP(object):
# finally, try the location system packages typically install into
dirs.append(os.path.sep.join(('', 'usr', 'share', 'vpp', 'api')))
- # check the directories for existance; first one wins
+ # check the directories for existence; first one wins
for dir in dirs:
if os.path.isdir(dir):
return dir
@@ -713,5 +714,7 @@ class VPP(object):
if self.event_callback:
self.event_callback(msgname, r)
+# Provide the old name for backward compatibility.
+VPP = VPPApiClient
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4