Skip to content

Commit 4af957c

Browse files
author
David Noble
committed
PEP-8 corrections
1 parent 3562774 commit 4af957c

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

splunklib/binding.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
"""
2626

2727
import httplib
28+
import logging
2829
import socket
2930
import ssl
3031
import urllib
31-
import functools
32-
import logging
32+
3333
from datetime import datetime
3434
from functools import wraps
3535
from 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
6869
class _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+
8284
class 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+
357363
class 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+
830837
def 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.
11051113
class 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+
11591168
def 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.

tests/test_job.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,17 @@ def test_setpriority(self):
232232
# Note that you can only *decrease* the priority (i.e., 5 decreased to 3)
233233
# of a job unless Splunk is running as root. This is because Splunk jobs
234234
# are tied up with operating system processes and their priorities.
235+
236+
if self.service._splunk_version[0] < 6:
237+
old_priority = int(self.job.content['priority'])
238+
self.assertEqual(5, old_priority)
239+
235240
new_priority = 3
236241
self.job.set_priority(new_priority)
237242

238-
while not self.job.is_ready():
239-
pass
240-
241-
self.assertEqual(5, int(self.job.content['priority']))
243+
if self.service._splunk_version[0] >= 6:
244+
while not self.job.is_ready():
245+
pass
242246

243247
def f():
244248
if self.job.is_done():
@@ -283,7 +287,6 @@ def test_pause(self):
283287
self.job.unpause()
284288
self.job.refresh()
285289
self.assertEqual(self.job['isPaused'], '0')
286-
287290
self.job.pause()
288291
self.assertEventuallyTrue(lambda: self.job.refresh()['isPaused'] == '1')
289292

0 commit comments

Comments
 (0)