2525"""
2626
2727import httplib
28+ import logging
2829import socket
2930import ssl
3031import urllib
31- import functools
32- import logging
32+
3333from datetime import datetime
3434from functools import wraps
3535from StringIO import StringIO
@@ -64,6 +64,7 @@ def new_f(*args, **kwargs):
6464 return val
6565 return new_f
6666
67+
6768# Singleton values to eschew None
6869class _NoAuthenticationToken (object ):
6970 """The value stored in a :class:`Context` or :class:`splunklib.client.Service`
@@ -79,6 +80,7 @@ class that is not logged in.
7980 """
8081 pass
8182
83+
8284class UrlEncoded (str ):
8385 """This class marks URL-encoded strings.
8486 It should be considered an SDK-private implementation detail.
@@ -240,10 +242,13 @@ def wrapper(self, *args, **kwargs):
240242 # an AuthenticationError and give up.
241243 with _handle_auth_error ("Autologin failed." ):
242244 self .login ()
243- with _handle_auth_error ("Autologin succeeded, but there was an auth error on next request. Something's very wrong." ):
245+ with _handle_auth_error (
246+ "Autologin succeeded, but there was an auth error on "
247+ "next request. Something is very wrong." ):
244248 return request_fun ()
245249 elif he .status == 401 and not self .autologin :
246- raise AuthenticationError ("Request failed: Session is not logged in." , he )
250+ raise AuthenticationError (
251+ "Request failed: Session is not logged in." , he )
247252 else :
248253 raise
249254
@@ -354,6 +359,7 @@ def namespace(sharing=None, owner=None, app=None, **kwargs):
354359 return record ({'sharing' : sharing , 'owner' : owner , 'app' : app })
355360 raise ValueError ("Invalid value for argument: 'sharing'" )
356361
362+
357363class Context (object ):
358364 """This class represents a context that encapsulates a splunkd connection.
359365
@@ -827,6 +833,7 @@ def _abspath(self, path_segment,
827833 skip_encode = skip_encode )
828834 return path
829835
836+
830837def connect (** kwargs ):
831838 """This function returns an authenticated :class:`Context` object.
832839
@@ -1101,6 +1108,7 @@ def request(self, url, message, **kwargs):
11011108 raise HTTPError (response )
11021109 return response
11031110
1111+
11041112# Converts an httplib response into a file-like object.
11051113class ResponseReader (object ):
11061114 """This class provides a file-like interface for :class:`httplib` responses.
@@ -1156,6 +1164,7 @@ def read(self, size = None):
11561164 r = r + self ._response .read (size )
11571165 return r
11581166
1167+
11591168def handler (key_file = None , cert_file = None , timeout = None ):
11601169 """This class returns an instance of the default HTTP request handler using
11611170 the values you provide.
0 commit comments