diff --git a/.travis.yml b/.travis.yml index a0b8e87..7eab46f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,15 @@ language: python python: - - "2.6" - "2.7" + - "3.0" + - "3.1" - "3.2" - "3.3" - "3.4" + - "3.5" + - "3.6" install: - pip install requests future -script: py.test \ No newline at end of file +script: py.test3 \ No newline at end of file diff --git a/logzio/sender.py b/logzio/sender.py index 1addf5e..e504c6d 100644 --- a/logzio/sender.py +++ b/logzio/sender.py @@ -92,7 +92,7 @@ class LogzioSender: break except Exception as e: - print("Got exception while sending logs to Logz.io, Try ({}/{}). Message: {}".format(current_try + 1, number_of_retries, e.message)) + print("Got exception while sending logs to Logz.io, Try ({}/{}). Message: {}".format(current_try + 1, number_of_retries, e)) should_retry = True if should_retry: diff --git a/tests/mockLogzioListener/listener.py b/tests/mockLogzioListener/listener.py index c925174..0a3b79a 100644 --- a/tests/mockLogzioListener/listener.py +++ b/tests/mockLogzioListener/listener.py @@ -12,26 +12,32 @@ class ListenerHandler(BaseHTTPRequestHandler): def do_POST(self): try: content_length = int(self.headers.get("Content-Length")) - all_logs = self.rfile.read(content_length).split('\n') + all_logs = self.rfile.read(content_length).decode("utf-8").split('\n') if len(all_logs) == 0: - self.send_response(400, "Bad Request") + self._set_response(400, "Bad Request", b"Bad request you got there, pal") return for log in all_logs: if log != "": if persistent_flags.get_server_error(): - self.send_response(500, "Issue!!!!!!!") + self._set_response(500, "Issue!!!!!!!", b"Not good, not good at all.") return logs_list.list.append(log) - self.send_response(200, "Ok") + self._set_response(200, "OK", b"Shabam! got logs.") return except IndexError: - self.send_response(400, "Bad Request") + self._set_response(400, "Bad Request", b"Bad request you got there, pal") return + def _set_response(self, http_code, http_description, byte_body): + self.send_response(http_code, http_description) + self.send_header('Content-type', 'text/html') + self.end_headers() + self.wfile.write(byte_body) + class MockLogzioListener: def __init__(self):