Commit 1021869d authored by JackV's avatar JackV

Python3 corrections

parent d7a9922d
#! /usr/bin/env python2 #! /usr/bin/env python3
from bitsd.main import main from bitsd.main import main
......
...@@ -26,7 +26,7 @@ def send(string): ...@@ -26,7 +26,7 @@ def send(string):
LOG.error("No Fonera connected! Not sending %r", string) LOG.error("No Fonera connected! Not sending %r", string)
return return
try: try:
RemoteListener.STREAM.write(string) RemoteListener.STREAM.write(string.encode('utf-8'))
except StreamClosedError as error: except StreamClosedError as error:
LOG.error('Could not push message to Fonera! %s', error) LOG.error('Could not push message to Fonera! %s', error)
...@@ -107,7 +107,7 @@ class RemoteListener(tornado.tcpserver.TCPServer): ...@@ -107,7 +107,7 @@ class RemoteListener(tornado.tcpserver.TCPServer):
# Meanwhile, go on with commands... # Meanwhile, go on with commands...
RemoteListener.STREAM.read_until(b'\n', self.handle_command) RemoteListener.STREAM.read_until(b'\n', self.handle_command)
command = command.strip('\n') command = command.strip(b'\n')
if command: if command:
args = command.split(b' ') args = command.split(b' ')
......
...@@ -93,6 +93,8 @@ def query_by_attribute(session, model, attribute, value, first=True): ...@@ -93,6 +93,8 @@ def query_by_attribute(session, model, attribute, value, first=True):
"""Query all instances of `model` having `attribute == value`. """Query all instances of `model` having `attribute == value`.
If first is True, only first result will be returned (useful If first is True, only first result will be returned (useful
if attribute is a primary/candidate key).""" if attribute is a primary/candidate key)."""
if isinstance(value, bytes):
value = value.decode('utf-8')
query = session.query(model).filter_by(**{attribute: value}) query = session.query(model).filter_by(**{attribute: value})
result = query.first() if first else query result = query.first() if first else query
return result return result
......
...@@ -338,6 +338,7 @@ class MessagePageHandler(BaseHandler): ...@@ -338,6 +338,7 @@ class MessagePageHandler(BaseHandler):
with session_scope() as session: with session_scope() as session:
user = query.get_user(session, username) user = query.get_user(session, username)
print(user)
message = query.log_message(session, user, text) message = query.log_message(session, user, text)
LOG.info("Broadcasting to clients") LOG.info("Broadcasting to clients")
broadcast(message.jsondict()) broadcast(message.jsondict())
......
#! /usr/bin/env python2 #! /usr/bin/env python3
# #
# Copyright (C) 2013 Stefano Sanfilippo # Copyright (C) 2013 Stefano Sanfilippo
# Copyright (C) 2013 BITS development team # Copyright (C) 2013 BITS development team
...@@ -29,6 +29,6 @@ if __name__ == '__main__': ...@@ -29,6 +29,6 @@ if __name__ == '__main__':
start() start()
with open('INFO.md', 'r') as info: with open('INFO.md', 'r') as info:
infopage = Page('Info', info.read().decode('utf-8')) infopage = Page('Info', info.read())
with session_scope() as session: with session_scope() as session:
persist(session, infopage) persist(session, infopage)
#! /usr/bin/env python2 #! /usr/bin/env python3
# #
# Copyright (C) 2013 Stefano Sanfilippo # Copyright (C) 2013 Stefano Sanfilippo
# Copyright (C) 2013 BITS development team # Copyright (C) 2013 BITS development team
...@@ -23,8 +23,7 @@ setup( ...@@ -23,8 +23,7 @@ setup(
'markdown', 'markdown',
'futures', 'futures',
'pycares', 'pycares',
'passlib', 'passlib'
'recaptcha'
], ],
packages=[ packages=[
'bitsd', 'bitsd',
......
#! /usr/bin/env python2 #! /usr/bin/env python3
# #
# Copyright (C) 2013 Stefano Sanfilippo # Copyright (C) 2013 Stefano Sanfilippo
# Copyright (C) 2013 BITS development team # Copyright (C) 2013 BITS development team
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment