diff options
author | Simo Sorce <simo@redhat.com> | 2015-03-25 15:45:19 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2015-03-25 15:47:08 -0400 |
commit | d40890b01fb600f09127cff0285472dfbba30442 (patch) | |
tree | db39bdd85a3b9156d26274ebe92c2d95de72405c | |
parent | 98085f982e98466b994c033be55047ce370dcac5 (diff) | |
download | custodia-d40890b01fb600f09127cff0285472dfbba30442.tar.gz custodia-d40890b01fb600f09127cff0285472dfbba30442.tar.xz custodia-d40890b01fb600f09127cff0285472dfbba30442.zip |
Adjust the code to be python3 happy
This required the renaming of the http directory to avoid clashes with the
python3 own http/server module.
-rw-r--r-- | custodia.conf | 4 | ||||
-rwxr-xr-x | custodia/custodia | 4 | ||||
-rw-r--r-- | custodia/httpd/__init__.py (renamed from custodia/http/__init__.py) | 0 | ||||
-rw-r--r-- | custodia/httpd/authenticators.py (renamed from custodia/http/authenticators.py) | 2 | ||||
-rw-r--r-- | custodia/httpd/consumer.py (renamed from custodia/http/consumer.py) | 2 | ||||
-rw-r--r-- | custodia/httpd/server.py (renamed from custodia/http/server.py) | 13 | ||||
-rw-r--r-- | custodia/root.py | 2 |
7 files changed, 14 insertions, 13 deletions
diff --git a/custodia.conf b/custodia.conf index 4a32c11..f7a1701 100644 --- a/custodia.conf +++ b/custodia.conf @@ -2,12 +2,12 @@ server_version = "Secret/0.0.7" [auth:simple] -handler = custodia.http.authenticators.SimpleCredsAuth +handler = custodia.httpd.authenticators.SimpleCredsAuth uid = 48 gid = 48 [auth:header] -handler = custodia.http.authenticators.SimpleHeaderAuth +handler = custodia.httpd.authenticators.SimpleHeaderAuth name = REMOTE_USER value = simo diff --git a/custodia/custodia b/custodia/custodia index 4bcb7cb..63b917c 100755 --- a/custodia/custodia +++ b/custodia/custodia @@ -6,7 +6,7 @@ try: from ConfigParser import RawConfigParser except ImportError: from configparser import RawConfigParser -from custodia.http.server import LocalHTTPServer +from custodia.httpd.server import LocalHTTPServer import importlib import os import sys @@ -65,7 +65,7 @@ def parse_config(cfgfile): module, classname = val.rsplit('.', 1) m = importlib.import_module(module) handler = getattr(m, classname) - except Exception, e: # pylint: disable=broad-except + except Exception as e: # pylint: disable=broad-except raise ValueError('Invalid format for "handler" option ' '[%r]' % e) diff --git a/custodia/http/__init__.py b/custodia/httpd/__init__.py index e69de29..e69de29 100644 --- a/custodia/http/__init__.py +++ b/custodia/httpd/__init__.py diff --git a/custodia/http/authenticators.py b/custodia/httpd/authenticators.py index 8bd9284..8a1bff5 100644 --- a/custodia/http/authenticators.py +++ b/custodia/httpd/authenticators.py @@ -1,6 +1,6 @@ # Copyright (C) 2015 Custodia Project Contributors - see LICENSE file -from custodia.http.server import HTTPError +from custodia.httpd.server import HTTPError import os diff --git a/custodia/http/consumer.py b/custodia/httpd/consumer.py index 1aa4978..1947b29 100644 --- a/custodia/http/consumer.py +++ b/custodia/httpd/consumer.py @@ -1,6 +1,6 @@ # Copyright (C) 2015 Custodia Project Contributors - see LICENSE file -from custodia.http.server import HTTPError +from custodia.httpd.server import HTTPError DEFAULT_CTYPE = 'text/html; charset=utf-8' diff --git a/custodia/http/server.py b/custodia/httpd/server.py index 423af9c..ed38ce6 100644 --- a/custodia/http/server.py +++ b/custodia/httpd/server.py @@ -11,6 +11,7 @@ except ImportError: import io import os import shutil +import six import socket import struct import sys @@ -138,22 +139,22 @@ class LocalHTTPRequestHandler(BaseHTTPRequestHandler): response = self.server.pipeline(request) if response is None: raise HTTPError(500) - except HTTPError, e: + except HTTPError as e: self.send_error(e.code, e.mesg) self.wfile.flush() return - except socket.timeout, e: + except socket.timeout as e: self.log_error("Request timed out: %r", e) self.close_connection = 1 return - except Exception, e: # pylint: disable=broad-except + except Exception as e: # pylint: disable=broad-except self.log_error("Handler failed: %r", e) self.log_traceback() self.send_error(500) self.wfile.flush() return self.send_response(response.get('code', 200)) - for header, value in response.get('headers', {}).iteritems(): + for header, value in six.iteritems(response.get('headers', {})): self.send_header(header, value) self.end_headers() output = response.get('output', None) @@ -161,10 +162,10 @@ class LocalHTTPRequestHandler(BaseHTTPRequestHandler): shutil.copyfileobj(output, self.wfile) output.close() else: - self.wfile.write(output) + self.wfile.write(output.encode('utf-8')) self.wfile.flush() return - except socket.timeout, e: + except socket.timeout as e: self.log_error("Request timed out: %r", e) self.close_connection = 1 return diff --git a/custodia/root.py b/custodia/root.py index ae11b2d..d02557a 100644 --- a/custodia/root.py +++ b/custodia/root.py @@ -1,7 +1,7 @@ # Copyright (C) 2015 Custodia Project Contributors - see LICENSE file import json -from custodia.http.consumer import HTTPConsumer +from custodia.httpd.consumer import HTTPConsumer class Root(HTTPConsumer): |