Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code updates for Python 3 #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/push.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pywebpush import webpush, WebPushException
import configuration
import thread
import _thread
from pymongo import MongoClient
import userio
import json
Expand Down
14 changes: 7 additions & 7 deletions src/webserver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import datetime
import httplib
import http.client
import json

import tornado
Expand Down Expand Up @@ -29,7 +29,7 @@ def get_ip(request):

class IndexHandler(tornado.web.RequestHandler):
def write_error(self, status_code, **kwargs):
self.render("pages/error.html", message=httplib.responses[status_code], error=status_code)
self.render("pages/error.html", message=http.client.responses[status_code], error=status_code)

def get(self):
try:
Expand All @@ -40,7 +40,7 @@ def get(self):
alerts = flashes.get_latest_flashes(3)
for flash in alerts:
flash['text'] = tornado.escape.xhtml_unescape(flash['text'])
if isinstance(flash['time'], basestring) and "+0000" in flash['time']:
if isinstance(flash['time'], str) and "+0000" in flash['time']:
flash['time'] = arrow.Arrow.strptime(flash['time'], "%a %b %d %H:%M:%S +0000 %Y").humanize()
if isinstance(flash['time'], datetime.datetime):
flash['time'] = arrow.get(flash['time']).humanize()
Expand All @@ -50,7 +50,7 @@ def get(self):

class StatsHandler(tornado.web.RequestHandler):
def write_error(self, status_code, **kwargs):
self.render("pages/error.html", message=httplib.responses[status_code], error=status_code)
self.render("pages/error.html", message=http.client.responses[status_code], error=status_code)

def get(self):
try:
Expand All @@ -65,7 +65,7 @@ def get(self):

class ApiHandler(tornado.web.RequestHandler):
def write_error(self, status_code, **kwargs):
self.render("pages/error.html", message=httplib.responses[status_code], error=status_code)
self.render("pages/error.html", message=http.client.responses[status_code], error=status_code)

def get(self):
try:
Expand All @@ -85,7 +85,7 @@ def get(self):
"latest": [flash for flash in flashes.get_latest_flashes(25)
if int(flash['id']) > int(latest)]
}
self.write(unicode(json.dumps(data, sort_keys=True, separators=(',', ':'))))
self.write(str(json.dumps(data, sort_keys=True, separators=(',', ':'))))


class ErrorHandler(tornado.web.RequestHandler):
Expand All @@ -94,7 +94,7 @@ def write_error(self, status_code, **kwargs):
stats.request(str(get_ip(self.request)))
except:
error("Errored while handling request IP -- still served...")
self.render("pages/error.html", message=httplib.responses[status_code], error=status_code)
self.render("pages/error.html", message=http.client.responses[status_code], error=status_code)

def get(self):
try:
Expand Down