From 1fb7b2cbe1da595d399128a6d532d0f01c5d8c64 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 20 May 2015 18:19:23 +0200 Subject: [PATCH] Compatibility with python3 --- helpers/statuspage.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/helpers/statuspage.py b/helpers/statuspage.py index 2819beeb..4e97f17a 100644 --- a/helpers/statuspage.py +++ b/helpers/statuspage.py @@ -1,14 +1,19 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import json +import sys + +if sys.hexversion >= 0x03000000: + from http.server import BaseHTTPRequestHandler, HTTPServer +else: + from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class StatusPage(BaseHTTPRequestHandler): def do_GET(self): - content_type='text/plain' + content_type = 'text/plain' if self.path == '/pg_master': if not self.pg_is_in_recovery(): response, content = 200, 'I am currently a master' @@ -67,7 +72,7 @@ if __name__ == '__main__': logging.basicConfig(format='%(levelname)-6s %(asctime)s - %(message)s', level=logging.DEBUG) logging.debug('Starting as a standalone application') - # # Create a dummy configuration to be able to use the Postgresql class + # Create a dummy configuration to be able to use the Postgresql class from postgresql import Postgresql postgres_config = { 'name': 'dummy',