diff --git a/docs/conf.py b/docs/conf.py index 63f1872..b0ed62a 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,8 +40,8 @@ master_doc = 'index' # General information about the project. -project = u'Cryptully' -copyright = u'2013, Shane Tully' +project = 'Cryptully' +copyright = '2013, Shane Tully' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -183,8 +183,8 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'Cryptully.tex', u'Cryptully Documentation', - u'Shane Tully', 'manual'), + ('index', 'Cryptully.tex', 'Cryptully Documentation', + 'Shane Tully', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -213,8 +213,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'cryptully', u'Cryptully Documentation', - [u'Shane Tully'], 1) + ('index', 'cryptully', 'Cryptully Documentation', + ['Shane Tully'], 1) ] # If true, show URL addresses after external links. @@ -227,8 +227,8 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Cryptully', u'Cryptully Documentation', - u'Shane Tully', 'Cryptully', 'One line description of project.', + ('index', 'Cryptully', 'Cryptully Documentation', + 'Shane Tully', 'Cryptully', 'One line description of project.', 'Miscellaneous'), ] diff --git a/make.py b/make.py index 211af3c..f84ea71 100755 --- a/make.py +++ b/make.py @@ -19,7 +19,7 @@ def deleteDirectory(path): except OSError as ose: # Ignore 'no such file or directory' errors if ose.errno != 2: - print ose + print(ose) def deleteFile(path): @@ -27,7 +27,7 @@ def deleteFile(path): os.unlink(path) except OSError as ose: if ose.errno != 2: - print ose + print(ose) arg = sys.argv[1] if len(sys.argv) >= 2 else None @@ -36,13 +36,13 @@ def deleteFile(path): if len(sys.argv) == 3: pyinstallerPath = sys.argv[2] else: - pyinstallerPath = raw_input("Path to pyinstaller: ") + pyinstallerPath = input("Path to pyinstaller: ") clean() subprocess.call(['python2.7', os.path.join(pyinstallerPath, 'pyinstaller.py'), 'cryptully.spec']) elif arg == 'deb': - print "Ensure you have the python-stdeb package installed!" + print("Ensure you have the python-stdeb package installed!") subprocess.call(['python2.7', 'setup.py', '--command-packages=stdeb.command', 'bdist_deb']) elif arg == 'rpm': @@ -66,4 +66,4 @@ def deleteFile(path): clean() else: - print "Invalid option\nPossible options: dist, deb, rpm, install, source, run, test, clean" + print("Invalid option\nPossible options: dist, deb, rpm, install, source, run, test, clean") diff --git a/src/__main__.py b/src/__main__.py index 3b695fb..fc3f54b 100755 --- a/src/__main__.py +++ b/src/__main__.py @@ -1,3 +1,3 @@ -import cryptully +from . import cryptully cryptully.main() diff --git a/src/crypto/crypto.py b/src/crypto/crypto.py index a841bb4..9aadce2 100755 --- a/src/crypto/crypto.py +++ b/src/crypto/crypto.py @@ -208,10 +208,10 @@ def __generateFingerprint(self, key): def __octx_to_num(self, data): - converted = 0L + converted = 0 length = len(data) for i in range(length): - converted = converted + ord(data[i]) * (256L ** (length - i - 1)) + converted = converted + ord(data[i]) * (256 ** (length - i - 1)) return converted diff --git a/src/crypto/smp.py b/src/crypto/smp.py index 2621639..e64a95f 100755 --- a/src/crypto/smp.py +++ b/src/crypto/smp.py @@ -1,4 +1,4 @@ -import crypto +from . import crypto import M2Crypto import struct @@ -221,7 +221,7 @@ def isValidArgument(self, val): def hash(self, message): - return long(self.crypto.stringHash(message), 16) + return int(self.crypto.stringHash(message), 16) @@ -263,8 +263,8 @@ def bytesToLong(bytes): def longToBytes(long): bytes = '' - while long != 0: - bytes = longToByte(long & 0xff) + bytes + while int != 0: + bytes = longToByte(int & 0xff) + bytes long >>= 8 return bytes @@ -274,7 +274,7 @@ def byteToLong(byte): def longToByte(long): - return struct.pack('B', long) + return struct.pack('B', int) def mulm(x, y, mod): diff --git a/src/cryptully.py b/src/cryptully.py index df75102..4c553f8 100755 --- a/src/cryptully.py +++ b/src/cryptully.py @@ -4,7 +4,7 @@ import signal import argparse -from utils import constants +from .utils import constants turnServer = None @@ -18,19 +18,19 @@ def main(): signal.signal(signal.SIGINT, signalHandler) if args.server: - from server.turnServer import TURNServer + from .server.turnServer import TURNServer global turnServer turnServer = TURNServer(args.port) turnServer.start() elif args.ncurses: - from ncurses.ncurses import NcursesUI + from .ncurses.ncurses import NcursesUI global ncursesUI ncursesUI = NcursesUI(args.nick, args.turn, args.port) ncursesUI.start() else: - from qt.qt import QtUI + from .qt.qt import QtUI global qtUI qtUI = QtUI(sys.argv, args.nick, args.turn, args.port) @@ -51,7 +51,7 @@ def parse_cmdline_args(): # Check the port range if args.port <= 0 or args.port > 65536: - print "The port must be between 1 and 65536 inclusive." + print("The port must be between 1 and 65536 inclusive.") sys.exit(1) return args diff --git a/src/ncurses/ncurses.py b/src/ncurses/ncurses.py index b60c88d..4b2c2ef 100755 --- a/src/ncurses/ncurses.py +++ b/src/ncurses/ncurses.py @@ -2,19 +2,19 @@ import curses.ascii import curses.textpad import os -import Queue +import queue import signal import sys import threading import time -from cursesAcceptDialog import CursesAcceptDialog -from cursesDialog import CursesDialog -from cursesInputDialog import CursesInputDialog -from cursesModeDialog import CursesModeDialog -from cursesPassphraseDialog import CursesPassphraseDialog -from cursesSendThread import CursesSendThread -from cursesStatusWindow import CursesStatusWindow +from .cursesAcceptDialog import CursesAcceptDialog +from .cursesDialog import CursesDialog +from .cursesInputDialog import CursesInputDialog +from .cursesModeDialog import CursesModeDialog +from .cursesPassphraseDialog import CursesPassphraseDialog +from .cursesSendThread import CursesSendThread +from .cursesStatusWindow import CursesStatusWindow from network.client import Client from network.connectionManager import ConnectionManager @@ -34,7 +34,7 @@ def __init__(self, nick, turn, port): self.connectedNick = None self.inRecveiveLoop = False self.clientConnectError = False - self.messageQueue = Queue.Queue() + self.messageQueue = queue.Queue() self.connectionManager = None self.sendThread = None diff --git a/src/network/client.py b/src/network/client.py index 9fe62e2..00f6b8a 100755 --- a/src/network/client.py +++ b/src/network/client.py @@ -1,10 +1,10 @@ import base64 -import Queue +import queue from crypto.crypto import Crypto from crypto.smp import SMP -from message import Message +from .message import Message from threading import Thread @@ -32,7 +32,7 @@ def __init__(self, connectionManager, remoteNick, sendMessageCallback, recvMessa self.outgoingMessageNum = 0 self.isEncrypted = False self.wasHandshakeDone = False - self.messageQueue = Queue.Queue() + self.messageQueue = queue.Queue() self.crypto = Crypto() self.crypto.generateDHKey() @@ -142,7 +142,7 @@ def __doHandshake(self): # Receive the client's public key clientPublicKey = self.__getHandshakeMessagePayload(constants.COMMAND_PUBLIC_KEY) - self.crypto.computeDHSecret(long(base64.b64decode(clientPublicKey))) + self.crypto.computeDHSecret(int(base64.b64decode(clientPublicKey))) # Send our public key publicKey = base64.b64encode(str(self.crypto.getDHPubKey())) @@ -174,7 +174,7 @@ def __initiateHandshake(self): # Receive the client's public key clientPublicKey = self.__getHandshakeMessagePayload(constants.COMMAND_PUBLIC_KEY) - self.crypto.computeDHSecret(long(base64.b64decode(clientPublicKey))) + self.crypto.computeDHSecret(int(base64.b64decode(clientPublicKey))) # Switch to AES encryption for the remainder of the connection self.isEncrypted = True diff --git a/src/network/connectionManager.py b/src/network/connectionManager.py index 7fa4eca..12244cf 100755 --- a/src/network/connectionManager.py +++ b/src/network/connectionManager.py @@ -1,13 +1,13 @@ -import Queue +import queue import socket import sys import traceback from threading import Thread -from client import Client -from message import Message -from sock import Socket +from .client import Client +from .message import Message +from .sock import Socket from utils import constants from utils import exceptions @@ -28,7 +28,7 @@ def __init__(self, nick, serverAddr, recvMessageCallback, newClientCallback, han self.errorCallback = errorCallback self.sendThread = SendThread(self.sock, self.errorCallback) self.recvThread = RecvThread(self.sock, self.recvMessage, self.errorCallback) - self.messageQueue = Queue.Queue() + self.messageQueue = queue.Queue() def connectToServer(self): @@ -43,7 +43,7 @@ def disconnectFromServer(self): if self.sock.isConnected: try: # Send the end command to all clients - for nick, client in self.clients.iteritems(): + for nick, client in self.clients.items(): client.disconnect() # Send the end command to the server @@ -189,7 +189,7 @@ def __init__(self, sock, errorCallback): self.sock = sock self.errorCallback = errorCallback - self.messageQueue = Queue.Queue() + self.messageQueue = queue.Queue() def run(self): diff --git a/src/network/qtThreads.py b/src/network/qtThreads.py index 5c90f84..456624e 100755 --- a/src/network/qtThreads.py +++ b/src/network/qtThreads.py @@ -1,4 +1,4 @@ -from client import Client +from .client import Client from PyQt4.QtCore import QThread from PyQt4.QtCore import pyqtSignal diff --git a/src/qt/qChatTab.py b/src/qt/qChatTab.py index a30acd8..89725f5 100755 --- a/src/qt/qChatTab.py +++ b/src/qt/qChatTab.py @@ -9,11 +9,11 @@ from PyQt4.QtGui import QStackedWidget from PyQt4.QtGui import QWidget -import qtUtils -from qChatWidget import QChatWidget -from qConnectingWidget import QConnectingWidget -from qHelpDialog import QHelpDialog -from qNickInputWidget import QNickInputWidget +from . import qtUtils +from .qChatWidget import QChatWidget +from .qConnectingWidget import QConnectingWidget +from .qHelpDialog import QHelpDialog +from .qNickInputWidget import QNickInputWidget from utils import errors diff --git a/src/qt/qChatWidget.py b/src/qt/qChatWidget.py index 4166838..c6fc42d 100755 --- a/src/qt/qChatWidget.py +++ b/src/qt/qChatWidget.py @@ -11,7 +11,7 @@ from PyQt4.QtGui import QTextEdit from PyQt4.QtGui import QWidget -import qtUtils +from . import qtUtils from utils import constants from utils import utils diff --git a/src/qt/qChatWindow.py b/src/qt/qChatWindow.py index dd0e517..191096b 100755 --- a/src/qt/qChatWindow.py +++ b/src/qt/qChatWindow.py @@ -23,12 +23,12 @@ from PyQt4.QtGui import QVBoxLayout from PyQt4.QtGui import QWidget -from qChatTab import QChatTab -from qAcceptDialog import QAcceptDialog -from qHelpDialog import QHelpDialog -from qSMPInitiateDialog import QSMPInitiateDialog -from qSMPRespondDialog import QSMPRespondDialog -import qtUtils +from .qChatTab import QChatTab +from .qAcceptDialog import QAcceptDialog +from .qHelpDialog import QHelpDialog +from .qSMPInitiateDialog import QSMPInitiateDialog +from .qSMPRespondDialog import QSMPRespondDialog +from . import qtUtils from utils import constants from utils import errors @@ -247,7 +247,7 @@ def sendMessageToTab(self, command, sourceNick, payload): elif payload == constants.TYPING_STOP_WITH_TEXT: self.statusBar.showMessage("%s has entered text" % sourceNick) elif command == constants.COMMAND_SMP_0: - print('got request for smp in tab %d' % (tabIndex)) + print(('got request for smp in tab %d' % (tabIndex))) else: tab.appendMessage(payload, constants.RECEIVER) diff --git a/src/qt/qConnectingWidget.py b/src/qt/qConnectingWidget.py index be85d37..33bde85 100755 --- a/src/qt/qConnectingWidget.py +++ b/src/qt/qConnectingWidget.py @@ -4,7 +4,7 @@ from PyQt4.QtGui import QMovie from PyQt4.QtGui import QWidget -import qtUtils +from . import qtUtils class QConnectingWidget(QWidget): diff --git a/src/qt/qHelpDialog.py b/src/qt/qHelpDialog.py index d6a5c73..3f4f83b 100755 --- a/src/qt/qHelpDialog.py +++ b/src/qt/qHelpDialog.py @@ -3,7 +3,7 @@ from PyQt4.QtGui import QLabel from PyQt4.QtGui import QVBoxLayout -from qLinkLabel import QLinkLabel +from .qLinkLabel import QLinkLabel class QHelpDialog(QMessageBox): def __init__(self, parent=None): diff --git a/src/qt/qLoginWindow.py b/src/qt/qLoginWindow.py index a82cd8b..722faba 100755 --- a/src/qt/qLoginWindow.py +++ b/src/qt/qLoginWindow.py @@ -10,9 +10,9 @@ from PyQt4.QtGui import QPushButton from PyQt4.QtGui import QVBoxLayout -from qNickInputWidget import QNickInputWidget -from qLinkLabel import QLinkLabel -import qtUtils +from .qNickInputWidget import QNickInputWidget +from .qLinkLabel import QLinkLabel +from . import qtUtils from utils import constants from utils import utils diff --git a/src/qt/qNickInputWidget.py b/src/qt/qNickInputWidget.py index 41773a6..458744e 100755 --- a/src/qt/qNickInputWidget.py +++ b/src/qt/qNickInputWidget.py @@ -8,7 +8,7 @@ from PyQt4.QtGui import QVBoxLayout from PyQt4.QtGui import QWidget -import qtUtils +from . import qtUtils from utils import constants from utils import errors diff --git a/src/qt/qPassphraseDialog.py b/src/qt/qPassphraseDialog.py index d4f4ae9..c598d92 100755 --- a/src/qt/qPassphraseDialog.py +++ b/src/qt/qPassphraseDialog.py @@ -9,7 +9,7 @@ from PyQt4.QtGui import QPushButton from PyQt4.QtGui import QVBoxLayout -import qtUtils +from . import qtUtils from utils import constants diff --git a/src/qt/qSMPInitiateDialog.py b/src/qt/qSMPInitiateDialog.py index e1d3945..fa6f511 100644 --- a/src/qt/qSMPInitiateDialog.py +++ b/src/qt/qSMPInitiateDialog.py @@ -11,8 +11,8 @@ from PyQt4.QtGui import QPushButton from PyQt4.QtGui import QVBoxLayout -from qLine import QLine -import qtUtils +from .qLine import QLine +from . import qtUtils from utils import constants diff --git a/src/qt/qSMPRespondDialog.py b/src/qt/qSMPRespondDialog.py index b049d86..419b072 100644 --- a/src/qt/qSMPRespondDialog.py +++ b/src/qt/qSMPRespondDialog.py @@ -11,8 +11,8 @@ from PyQt4.QtGui import QPushButton from PyQt4.QtGui import QVBoxLayout -from qLine import QLine -import qtUtils +from .qLine import QLine +from . import qtUtils from utils import constants diff --git a/src/qt/qWaitingDialog.py b/src/qt/qWaitingDialog.py index 7e6a881..30d730c 100755 --- a/src/qt/qWaitingDialog.py +++ b/src/qt/qWaitingDialog.py @@ -6,8 +6,8 @@ from PyQt4.QtGui import QMovie from PyQt4.QtGui import QVBoxLayout -import qtUtils -from qLine import QLine +from . import qtUtils +from .qLine import QLine from utils import constants diff --git a/src/qt/qt.py b/src/qt/qt.py index a0d0b97..7a10b4d 100755 --- a/src/qt/qt.py +++ b/src/qt/qt.py @@ -13,11 +13,11 @@ from PyQt4.QtGui import QPalette from PyQt4.QtGui import QWidget -from qAcceptDialog import QAcceptDialog -from qChatWindow import QChatWindow -from qLoginWindow import QLoginWindow -import qtUtils -from qWaitingDialog import QWaitingDialog +from .qAcceptDialog import QAcceptDialog +from .qChatWindow import QChatWindow +from .qLoginWindow import QLoginWindow +from . import qtUtils +from .qWaitingDialog import QWaitingDialog from utils import constants from utils import errors diff --git a/src/qt/qtUtils.py b/src/qt/qtUtils.py index 9164eb3..e0be701 100755 --- a/src/qt/qtUtils.py +++ b/src/qt/qtUtils.py @@ -10,7 +10,7 @@ from PyQt4.QtGui import QPixmap from PyQt4.QtGui import QWidget -from qPassphraseDialog import QPassphraseDialog +from .qPassphraseDialog import QPassphraseDialog from utils import constants from utils import utils diff --git a/src/server/console.py b/src/server/console.py index 6249bc8..eb91457 100644 --- a/src/server/console.py +++ b/src/server/console.py @@ -41,7 +41,7 @@ def __init__(self, nickMap, ipMap): def run(self): while True: try: - input = raw_input(">> ").split() + input = input(">> ").split() if len(input) == 0: continue @@ -53,49 +53,49 @@ def run(self): except EOFError: self.stop() except KeyError: - print "Unrecognized command" + print("Unrecognized command") def list(self, arg): - print "Registered nicks" - print "================" + print("Registered nicks") + print("================") - for nick, client in self.nickMap.iteritems(): - print nick + " - " + str(client.sock) + for nick, client in self.nickMap.items(): + print(nick + " - " + str(client.sock)) def zombies(self, arg): - print "Zombie Connections" - print "==================" + print("Zombie Connections") + print("==================") - for addr, client in self.ipMap.iteritems(): - print addr + for addr, client in self.ipMap.items(): + print(addr) def kick(self, nick): if not nick: - print "Kick command requires a nick" + print("Kick command requires a nick") return try: client = self.nickMap[nick] client.kick() - print "%s kicked from server" % nick + print("%s kicked from server" % nick) except KeyError: - print "%s is not a registered nick" % nick + print("%s is not a registered nick" % nick) def kill(self, ip): if not ip: - print "Kill command requires an IP" + print("Kill command requires an IP") return try: client = self.ipMap[ip] client.kick() - print "%s killed" % ip + print("%s killed" % ip) except KeyError: - print "%s is not a zombie" % ip + print("%s is not a zombie" % ip) def stop(self, arg=None): @@ -104,5 +104,5 @@ def stop(self, arg=None): def help(self, arg): delimeter = '\n\t' - helpMessages = map(lambda (_, command): command['help'], self.commands.iteritems()) - print "Available commands:%s%s" % (delimeter, delimeter.join(helpMessages)) + helpMessages = [__command[1]['help'] for __command in iter(self.commands.items())] + print("Available commands:%s%s" % (delimeter, delimeter.join(helpMessages))) diff --git a/src/server/turnServer.py b/src/server/turnServer.py index 0219298..9fd4d13 100755 --- a/src/server/turnServer.py +++ b/src/server/turnServer.py @@ -1,11 +1,11 @@ -import Queue +import queue import socket import sys import time from threading import Thread -from console import Console +from .console import Console from network.message import Message from network.sock import Socket @@ -70,7 +70,7 @@ def startServer(self): def stop(self): printAndLog("Requested to stop server") - for nick, client in nickMap.iteritems(): + for nick, client in nickMap.items(): client.send(Message(serverCommand=constants.COMMAND_END, destNick=nick, error=errors.ERR_SERVER_SHUTDOWN)) # Give the send threads time to get their messages out @@ -86,7 +86,7 @@ def openLog(self): logFile = open('cryptully.log', 'a') except: logFile = None - print "Error opening logfile" + print("Error opening logfile") class Client(object): @@ -133,7 +133,7 @@ def __init__(self, sock): self.daemon = True self.sock = sock - self.queue = Queue.Queue() + self.queue = queue.Queue() def run(self): diff --git a/src/test.py b/src/test.py index 8c777b5..7846be9 100755 --- a/src/test.py +++ b/src/test.py @@ -2,8 +2,8 @@ import sys -from tests.mockServer import MockServer -from tests.mockClient import MockClient, Client1, Client2 +from .tests.mockServer import MockServer +from .tests.mockClient import MockClient, Client1, Client2 def test(): @@ -27,7 +27,7 @@ def test(): for client in clients: client.join() - print '' + print('') for client in clients: client.printExceptions() diff --git a/src/tests/mockClient.py b/src/tests/mockClient.py index 918a473..384314f 100644 --- a/src/tests/mockClient.py +++ b/src/tests/mockClient.py @@ -6,7 +6,7 @@ from network.connectionManager import ConnectionManager from utils import constants -from waitingMock import WaitingMock +from .waitingMock import WaitingMock class MockClient(Thread): @@ -46,7 +46,7 @@ def exception(self): def printExceptions(self): for exception in self.exceptions: - print "\n%s\n%s" % (exception[1], exception[0]) + print("\n%s\n%s" % (exception[1], exception[0])) class Client1(MockClient): diff --git a/src/utils/errors.py b/src/utils/errors.py index 8971a15..7d5dcc9 100755 --- a/src/utils/errors.py +++ b/src/utils/errors.py @@ -1,4 +1,4 @@ -import constants +from . import constants # Nick validation statuses VALID_NICK = 0 diff --git a/src/utils/utils.py b/src/utils/utils.py index a65f6c3..3fd61ff 100755 --- a/src/utils/utils.py +++ b/src/utils/utils.py @@ -1,8 +1,8 @@ import os import sys -import constants -import errors +from . import constants +from . import errors from time import localtime from time import strftime