Skip to content

Commit 7f5dd06

Browse files
Merge pull request splunk#191 from vaputa/master
python 3 support
2 parents f878496 + ed2f001 commit 7f5dd06

File tree

122 files changed

+2032
-853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+2032
-853
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ language: python
3737

3838
python:
3939
- "2.7"
40+
- "2.6"
41+
- "3.5"
4042

4143
install: "pip install unittest2"
4244

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,3 +558,4 @@ API reference under the section on accessing Splunk resources at:
558558
## 0.1.0 (preview)
559559

560560
* Initial Python SDK release
561+

examples/abc/a.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"""Retrieves a list of installed apps from Splunk by making REST API calls
1616
using Python's httplib module."""
1717

18-
import httplib
18+
from __future__ import absolute_import
19+
from __future__ import print_function
20+
import splunklib.six.moves.http_client
1921
import urllib
2022
from xml.etree import ElementTree
2123

@@ -25,7 +27,7 @@
2527
PASSWORD = "changeme"
2628

2729
# Present credentials to Splunk and retrieve the session key
28-
connection = httplib.HTTPSConnection(HOST, PORT)
30+
connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
2931
body = urllib.urlencode({'username': USERNAME, 'password': PASSWORD})
3032
headers = {
3133
'Content-Type': "application/x-www-form-urlencoded",
@@ -40,12 +42,12 @@
4042
finally:
4143
connection.close()
4244
if response.status != 200:
43-
raise Exception, "%d (%s)" % (response.status, response.reason)
45+
raise Exception("%d (%s)" % (response.status, response.reason))
4446
body = response.read()
4547
sessionKey = ElementTree.XML(body).findtext("./sessionKey")
4648

4749
# Now make the request to Splunk for list of installed apps
48-
connection = httplib.HTTPSConnection(HOST, PORT)
50+
connection = six.moves.http_client.HTTPSConnection(HOST, PORT)
4951
headers = {
5052
'Content-Length': "0",
5153
'Host': HOST,
@@ -59,10 +61,10 @@
5961
finally:
6062
connection.close()
6163
if response.status != 200:
62-
raise Exception, "%d (%s)" % (response.status, response.reason)
64+
raise Exception("%d (%s)" % (response.status, response.reason))
6365

6466
body = response.read()
6567
data = ElementTree.XML(body)
6668
apps = data.findall("{http://www.w3.org/2005/Atom}entry/{http://www.w3.org/2005/Atom}title")
6769
for app in apps:
68-
print app.text
70+
print(app.text)

examples/abc/b.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
"""Retrieves a list of installed apps from Splunk using the binding module."""
1616

17+
from __future__ import absolute_import
18+
from __future__ import print_function
1719
import sys, os
1820
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
1921

@@ -34,11 +36,11 @@
3436

3537
response = context.get('apps/local')
3638
if response.status != 200:
37-
raise Exception, "%d (%s)" % (response.status, response.reason)
39+
raise Exception("%d (%s)" % (response.status, response.reason))
3840

3941
body = response.body.read()
4042
data = ElementTree.XML(body)
4143
apps = data.findall("{http://www.w3.org/2005/Atom}entry/{http://www.w3.org/2005/Atom}title")
4244
for app in apps:
43-
print app.text
45+
print(app.text)
4446

examples/abc/c.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# under the License.
1414

1515
"""Retrieves a list of installed apps from Splunk using the client module."""
16+
from __future__ import absolute_import
17+
from __future__ import print_function
1618
import sys, os
1719
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", ".."))
1820

@@ -30,4 +32,4 @@
3032
password=PASSWORD)
3133

3234
for app in service.apps:
33-
print app.name
35+
print(app.name)

examples/analytics/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17-
import input
18-
import output
17+
from __future__ import absolute_import
18+
from . import input
19+
from . import output

0 commit comments

Comments
 (0)