-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1412 from garberg/pynipap_as_a_package
pynipap as a package
- Loading branch information
Showing
6 changed files
with
40 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from .pynipap import * | ||
|
||
__version__ = "0.32.5" | ||
__author__ = "Kristian Larsson, Lukas Garberg" | ||
__author_email__= "[email protected], [email protected]" | ||
__copyright__ = "Copyright 2011, Kristian Larsson, Lukas Garberg" | ||
__license__ = "MIT" | ||
__status__ = "Development" | ||
__url__ = "http://SpriteLink.github.io/NIPAP" | ||
|
||
|
||
# This variable holds the URI to the nipap XML-RPC service which will be used. | ||
# It must be set before the Pynipap can be used! | ||
xmlrpc_uri = None | ||
|
||
# If set, the value assigned to the variable below will be used as a bearer | ||
# token. | ||
bearer_token = None | ||
|
||
# Caching of objects is enabled per default but can be disabled for certain | ||
# scenarios. Since we don't have any cache expiration time it can be useful to | ||
# disable for long running applications. | ||
CACHE = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -209,27 +209,7 @@ | |
import xmlrpc.client as xmlrpclib | ||
import urllib.parse | ||
|
||
from tracing import create_span | ||
|
||
__version__ = "0.32.5" | ||
__author__ = "Kristian Larsson, Lukas Garberg" | ||
__author_email__= "[email protected], [email protected]" | ||
__copyright__ = "Copyright 2011, Kristian Larsson, Lukas Garberg" | ||
__license__ = "MIT" | ||
__status__ = "Development" | ||
__url__ = "http://SpriteLink.github.io/NIPAP" | ||
|
||
|
||
# This variable holds the URI to the nipap XML-RPC service which will be used. | ||
# It must be set before the Pynipap can be used! | ||
xmlrpc_uri = None | ||
bearer_token = None | ||
|
||
# Caching of objects is enabled per default but can be disabled for certain | ||
# scenarios. Since we don't have any cache expiration time it can be useful to | ||
# disable for long running applications. | ||
CACHE = True | ||
|
||
from .tracing import create_span | ||
class AuthOptions: | ||
""" A global-ish authentication option container. | ||
|
@@ -261,8 +241,6 @@ class XMLRPCConnection: | |
""" Handles a shared XML-RPC connection. | ||
""" | ||
|
||
__shared_state = {} | ||
|
||
connection = None | ||
_logger = None | ||
|
||
|
@@ -275,13 +253,19 @@ def __init__(self): | |
variable is set. | ||
""" | ||
|
||
# This is not a pretty solution, but needed to maintain backwards | ||
# compatibility and avoiding circular imports. | ||
from . import xmlrpc_uri, bearer_token, CACHE as cache_enabled | ||
global CACHE | ||
CACHE = cache_enabled | ||
|
||
if xmlrpc_uri is None: | ||
raise NipapError('XML-RPC URI not specified') | ||
|
||
p = urllib.parse.urlsplit(xmlrpc_uri) | ||
|
||
try: | ||
from tracing import TracingXMLTransport, TracingXMLSafeTransport | ||
from .tracing import TracingXMLTransport, TracingXMLSafeTransport | ||
if p.scheme == "http": | ||
xml_transport = TracingXMLTransport | ||
elif p.scheme == "https": | ||
|
@@ -1521,6 +1505,10 @@ class NipapAuthorizationError(NipapAuthError): | |
'VRF': {} | ||
} | ||
|
||
# Will be overwritten by import from . when setting up XML-RPC-connection, but | ||
# needs to be defined here if it's read before the connections is set up. | ||
CACHE = False | ||
|
||
# Map from XML-RPC Fault codes to Exception classes | ||
_fault_to_exception_map = { | ||
1000: NipapError, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters