Skip to content

Commit

Permalink
Imports are Python3 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
b4oshany committed Oct 21, 2017
1 parent 853f33a commit ce4526a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
syntax: glob
*.egg-info
*.mo
*.swp
*.pyc
*.py.bak
.DS_Store
.idea
.installed.cfg
Expand Down
14 changes: 14 additions & 0 deletions src/plone/app/robotframework/_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys


PY3 = sys.version_info[0] == 3
if PY3:
from http.client import HTTPConnection
from io import StringIO
from xmlrpc.client import ServerProxy
from xmlrpc.server import SimpleXMLRPCServer
else:
from httplib import HTTPConnection
from StringIO import StringIO
from xmlrpclib import ServerProxy
from SimpleXMLRPCServer import SimpleXMLRPCServer
4 changes: 2 additions & 2 deletions src/plone/app/robotframework/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def prefill_image_types(portal, kwargs):

def random_image():
import random
import StringIO
from plone.app.robotframework._compat import StringIO
from PIL import Image
from PIL import ImageDraw

Expand All @@ -300,7 +300,7 @@ def random_image():
)
del draw

result = StringIO.StringIO()
result = StringIO()
img.save(result, 'PNG')
result.seek(0)
return result
Expand Down
4 changes: 2 additions & 2 deletions src/plone/app/robotframework/saucelabs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import re
import os
import httplib
from plone.app.robotframework._compat import HTTPConnection
import base64
try:
import json
Expand Down Expand Up @@ -39,7 +39,7 @@ def report_sauce_status(self, name, status, tags=[], remote_url=''):
'passed': status == 'PASS',
'tags': tags})

connection = httplib.HTTPConnection('saucelabs.com')
connection = HTTPConnection('saucelabs.com')
connection.request('PUT', '/rest/v1/%s/jobs/%s' % (
username, job_id), body,
headers={'Authorization': 'Basic %s' % token}
Expand Down
6 changes: 3 additions & 3 deletions src/plone/app/robotframework/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import os
import sys
import time
import xmlrpclib
from SimpleXMLRPCServer import SimpleXMLRPCServer
from plone.app.robotframework._compat.xmlrpc.client import ServerProxy
from plone.app.robotframework._compat import SimpleXMLRPCServer

import pkg_resources

Expand Down Expand Up @@ -196,7 +196,7 @@ class RobotListener:
def __init__(self):
server_listener_address = 'http://%s:%s' % (
LISTENER_HOST, LISTENER_PORT)
self.server = xmlrpclib.ServerProxy(server_listener_address)
self.server = ServerProxy(server_listener_address)

def start_test(self, name, attrs):
self.server.zodb_setup()
Expand Down

0 comments on commit ce4526a

Please sign in to comment.