python3 compatibility
This commit is contained in:
parent
5f5e6cdbb6
commit
5f2342de72
2 changed files with 13 additions and 9 deletions
|
|
@ -1,13 +1,15 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import ast
|
||||
import cStringIO
|
||||
import os
|
||||
import os.path
|
||||
import pprint
|
||||
import sys
|
||||
import xmlrpclib
|
||||
from urllib import quote
|
||||
import six.moves.xmlrpc_client
|
||||
from six.moves import cStringIO
|
||||
from six.moves.urllib.parse import quote
|
||||
|
||||
sys.path.insert(0, os.getcwd())
|
||||
sys.path.insert(1, os.path.join(os.getcwd(), 'hub'))
|
||||
|
|
@ -56,7 +58,7 @@ def get_request():
|
|||
else:
|
||||
args.append(nice_literal(s))
|
||||
args = koji.encode_args(*args, **kwargs)
|
||||
request = xmlrpclib.dumps(args, method, allow_none=1)
|
||||
request = six.moves.xmlrpc_client.dumps(args, method, allow_none=1)
|
||||
return request
|
||||
|
||||
|
||||
|
|
@ -66,7 +68,7 @@ def start_response(status, headers):
|
|||
|
||||
|
||||
def parse_response(data):
|
||||
p, u = xmlrpclib.getparser()
|
||||
p, u = six.moves.xmlrpc_client.getparser()
|
||||
for chunk in data:
|
||||
p.feed(chunk)
|
||||
p.close()
|
||||
|
|
@ -91,7 +93,7 @@ def main():
|
|||
environ['SERVER_NAME'] = 'myserver'
|
||||
environ['SERVER_PORT'] = '443'
|
||||
environ['REQUEST_URI'] = get_url(environ)
|
||||
environ['wsgi.input'] = cStringIO.StringIO(get_request())
|
||||
environ['wsgi.input'] = cStringIO(get_request())
|
||||
environ['REQUEST_METHOD'] = 'POST'
|
||||
environ['CONTENT_TYPE'] = 'text/xml'
|
||||
set_config(environ)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import mimetypes
|
||||
import os
|
||||
import os.path
|
||||
import pprint
|
||||
import sys
|
||||
|
||||
from urllib import quote
|
||||
from six.moves.urllib.parse import quote
|
||||
from wsgiref.util import setup_testing_defaults
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
|
|
@ -53,7 +55,7 @@ def do_static(environ, start_response):
|
|||
path = path.lstrip('/')
|
||||
fn = os.path.join(CWD, 'www/static', path)
|
||||
if not os.path.exists(fn):
|
||||
print "No such file: %s" % fn
|
||||
print("No such file: %s" % fn)
|
||||
return do_404(environ, start_response)
|
||||
size = os.path.getsize(fn)
|
||||
ctype, encoding = mimetypes.guess_type(fn)
|
||||
|
|
@ -122,7 +124,7 @@ def application(environ, start_response):
|
|||
def main():
|
||||
# koji.add_file_logger('koji', 'fakeweb.log')
|
||||
httpd = make_server('', 8000, application)
|
||||
print "Serving on port 8000..."
|
||||
print("Serving on port 8000...")
|
||||
httpd.serve_forever()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue