diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a1f4944 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "C:\\Program Files (x86)\\Python39-32\\python.exe" +} \ No newline at end of file diff --git a/README.md b/README.md index c1089aa..1e0326c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ -Pyfire XMPP Project -=================== +Pyfire 2.0 XMPP Server Project +=============================== Having used some other implementations in the past, we decided to roll our own. Development just has begun, so don't expect anything fancy yet... Dependencies ============ -- Python 2.6 with ElementTree 1.3 or Python 2.7 +- Python 3.9 with ElementTree - Tornado - pyzmq (Python bindings for libzmq, ØMQ) - sqlalchemy diff --git a/bin/server.py b/bin/server.py index 70f88a9..5359195 100755 --- a/bin/server.py +++ b/bin/server.py @@ -20,7 +20,7 @@ import functools import contextlib import socket -import thread +import _thread from zmq.eventloop import ioloop @@ -45,7 +45,7 @@ def start_client_listener(): io_loop.start() except (KeyboardInterrupt, SystemExit): io_loop.stop() - print "exited cleanly" + print("exited cleanly") def fire_up(): import pyfire.storage diff --git a/pyfire/auth/registry.py b/pyfire/auth/registry.py index 1cad351..70e11d3 100644 --- a/pyfire/auth/registry.py +++ b/pyfire/auth/registry.py @@ -9,7 +9,7 @@ :license: BSD, see LICENSE for more details. """ -from thread import allocate_lock +from _thread import allocate_lock from pyfire.auth.backends import InvalidAuthenticationError diff --git a/pyfire/configuration.py b/pyfire/configuration.py index c49ee75..772358d 100644 --- a/pyfire/configuration.py +++ b/pyfire/configuration.py @@ -9,10 +9,10 @@ :license: BSD, see LICENSE for more details. """ -import ConfigParser +import configparser import os.path -config = ConfigParser.SafeConfigParser() +config = configparser.SafeConfigParser() config.add_section('database') config.set('database', 'dburi', 'sqlite:///pyfire.db') @@ -42,5 +42,5 @@ def getlist(section, option, separator=','): # some handy shortcuts get = config.get getint = config.getint -NoOptionError = ConfigParser.NoOptionError +NoOptionError = configparser.NoOptionError set = config.set diff --git a/pyfire/server.py b/pyfire/server.py index 79aa3ac..641ebca 100644 --- a/pyfire/server.py +++ b/pyfire/server.py @@ -111,7 +111,7 @@ def _handle_events(self, fd, events): while True: try: connection, address = self._sockets[fd].accept() - except socket.error, e: + except(socket.error, e): if e.args[0] in (errno.EWOULDBLOCK, errno.EAGAIN): return raise @@ -121,7 +121,7 @@ def _handle_events(self, fd, events): self._connections[address] = XMPPConnection(stream, address) if not self.checker._running: self.checker.start() - except Exception, e: + except (Exception, e): exc_type, exc_value, exc_traceback = sys.exc_info() log.error("Error in connection callback, %s" % str(e)) for line in traceback.format_tb(exc_traceback): diff --git a/pyfire/singletons.py b/pyfire/singletons.py index 45589b3..7eebbd4 100644 --- a/pyfire/singletons.py +++ b/pyfire/singletons.py @@ -9,7 +9,7 @@ :license: BSD, see LICENSE for more details. """ -from thread import allocate_lock +from _thread import allocate_lock import zmq diff --git a/pyfire/stanza_processor.py b/pyfire/stanza_processor.py index 242f03f..ce63b35 100644 --- a/pyfire/stanza_processor.py +++ b/pyfire/stanza_processor.py @@ -10,7 +10,7 @@ :license: BSD, see LICENSE for more details. """ -import cPickle +import pickle import zmq from zmq.eventloop import ioloop, zmqstream import xml.etree.ElementTree as ET @@ -76,6 +76,6 @@ def handle_stanza(self, msgs): self.forwarder.send(cPickle.dumps(resp)) else: self.forwarder.send(cPickle.dumps(response)) - except StanzaError, e: + except (StanzaError, e): # send caught errors back to sender self.forwarder.send(cPickle.dumps(e.element)) diff --git a/pyfire/stream/stanzas/__init__.py b/pyfire/stream/stanzas/__init__.py index 7a6bb8e..b09d075 100644 --- a/pyfire/stream/stanzas/__init__.py +++ b/pyfire/stream/stanzas/__init__.py @@ -9,9 +9,9 @@ :license: BSD, see LICENSE for more details. """ -import cPickle +import pickle import uuid -from thread import allocate_lock +from _thread import allocate_lock import xml.etree.ElementTree as ET import zmq @@ -103,7 +103,7 @@ def contenthandler(self, tree): raise NotAuthorizedError self.publish_stanza(tree) - except StreamError, e: + except(StreamError, e): self.send_string(unicode(e)) self.connection.stop_connection() diff --git a/pyfire/stream/stanzas/iq/query.py b/pyfire/stream/stanzas/iq/query.py index 6ac6973..e8d86ef 100644 --- a/pyfire/stream/stanzas/iq/query.py +++ b/pyfire/stream/stanzas/iq/query.py @@ -19,7 +19,7 @@ class Query(object): """Handles all iq-query xmpp frames""" - __slots__ = ('handler', 'request', 'response', 'sender') + __slots__ = ( 'request', 'response', 'sender') def handle(self, request, sender): self.request = request diff --git a/pyfire/zmq_forwarder.py b/pyfire/zmq_forwarder.py index bfbe452..9da98b9 100644 --- a/pyfire/zmq_forwarder.py +++ b/pyfire/zmq_forwarder.py @@ -12,7 +12,7 @@ import uuid import random -import cPickle +import pickle import zmq from zmq.eventloop import ioloop, zmqstream