diff --git a/.gitignore b/.gitignore index acfa0ca1..e0055bc7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ **.DS_Store src/build src/dist +src/.project +src/.pydevprojecy diff --git a/src/build_osx.py b/src/build_osx.py index de08da4c..db004769 100644 --- a/src/build_osx.py +++ b/src/build_osx.py @@ -9,7 +9,7 @@ Usage (Windows): """ import sys, os, shutil, re -from setuptools import setup +from setuptools import setup # @UnresolvedImport name = "Bitmessage" diff --git a/src/class_addressGenerator.py b/src/class_addressGenerator.py index e22fdd51..c19a294b 100644 --- a/src/class_addressGenerator.py +++ b/src/class_addressGenerator.py @@ -2,9 +2,11 @@ import shared import threading import bitmessagemain import time +import sys from pyelliptic.openssl import OpenSSL import ctypes import hashlib +import highlevelcrypto from addresses import * from pyelliptic import arithmetic diff --git a/src/class_outgoingSynSender.py b/src/class_outgoingSynSender.py index ee8c5640..d3310698 100644 --- a/src/class_outgoingSynSender.py +++ b/src/class_outgoingSynSender.py @@ -141,7 +141,7 @@ class outgoingSynSender(threading.Thread): shared.printLock.release() except socks.Socks5AuthError as err: shared.UISignalQueue.put(( - 'updateStatusBar', translateText( + 'updateStatusBar', bitmessagemain.translateText( "MainWindow", "SOCKS5 Authentication problem: %1").arg(str(err)))) except socks.Socks5Error as err: pass diff --git a/src/class_receiveDataThread.py b/src/class_receiveDataThread.py index decd9618..c1148667 100644 --- a/src/class_receiveDataThread.py +++ b/src/class_receiveDataThread.py @@ -7,9 +7,16 @@ import pickle import random from struct import unpack, pack import sys +import string +from subprocess import call # used when the API must execute an outside program +from pyelliptic.openssl import OpenSSL +import highlevelcrypto from addresses import * import helper_generic +import helper_bitcoin +import helper_inbox +import helper_sent import bitmessagemain from bitmessagemain import lengthOfTimeToLeaveObjectsInInventory, lengthOfTimeToHoldOnToAllPubkeys, maximumAgeOfAnObjectThatIAmWillingToAccept, maximumAgeOfObjectsThatIAdvertiseToOthers, maximumAgeOfNodesThatIAdvertiseToOthers, numberOfObjectsThatWeHaveYetToCheckAndSeeWhetherWeAlreadyHavePerPeer, neededPubkeys @@ -814,8 +821,8 @@ class receiveDataThread(threading.Thread): shared.sqlReturnQueue.get() shared.sqlSubmitQueue.put('commit') shared.sqlLock.release() - shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (encryptedData[readPosition:], translateText("MainWindow",'Acknowledgement of the message received. %1').arg(unicode( - strftime(shared.config.get('bitmessagesettings', 'timeformat'), localtime(int(time.time()))), 'utf-8'))))) + shared.UISignalQueue.put(('updateSentItemStatusByAckdata', (encryptedData[readPosition:], bitmessagemain.translateText("MainWindow",'Acknowledgement of the message received. %1').arg(unicode( + time.strftime(shared.config.get('bitmessagesettings', 'timeformat'), time.localtime(int(time.time()))), 'utf-8'))))) return else: shared.printLock.acquire() @@ -1046,7 +1053,7 @@ class receiveDataThread(threading.Thread): subject = self.addMailingListNameToSubject( subject, mailingListName) # Let us now send this message out as a broadcast - message = strftime("%a, %Y-%m-%d %H:%M:%S UTC", gmtime( + message = time.strftime("%a, %Y-%m-%d %H:%M:%S UTC", time.gmtime( )) + ' Message ostensibly from ' + fromAddress + ':\n\n' + body fromAddress = toAddress # The fromAddress for the broadcast that we are about to send is the toAddress (my address) for the msg message we are currently processing. ackdata = OpenSSL.rand( @@ -1069,14 +1076,14 @@ class receiveDataThread(threading.Thread): # Display timing data timeRequiredToAttemptToDecryptMessage = time.time( ) - self.messageProcessingStartTime - successfullyDecryptMessageTimings.append( + bitmessagemain.successfullyDecryptMessageTimings.append( timeRequiredToAttemptToDecryptMessage) sum = 0 - for item in successfullyDecryptMessageTimings: + for item in bitmessagemain.successfullyDecryptMessageTimings: sum += item shared.printLock.acquire() print 'Time to decrypt this message successfully:', timeRequiredToAttemptToDecryptMessage - print 'Average time for all message decryption successes since startup:', sum / len(successfullyDecryptMessageTimings) + print 'Average time for all message decryption successes since startup:', sum / len(bitmessagemain.successfullyDecryptMessageTimings) shared.printLock.release() def isAckDataValid(self, ackData): diff --git a/src/class_sendDataThread.py b/src/class_sendDataThread.py index 6773a868..1e3528dd 100644 --- a/src/class_sendDataThread.py +++ b/src/class_sendDataThread.py @@ -4,6 +4,9 @@ import shared import Queue from struct import unpack, pack import hashlib +import random +import sys +import socket import bitmessagemain diff --git a/src/class_singleCleaner.py b/src/class_singleCleaner.py index 999cda26..f04a5507 100644 --- a/src/class_singleCleaner.py +++ b/src/class_singleCleaner.py @@ -1,7 +1,9 @@ import threading import shared import time -from bitmessagemain import lengthOfTimeToLeaveObjectsInInventory, lengthOfTimeToHoldOnToAllPubkeys, maximumAgeOfAnObjectThatIAmWillingToAccept, maximumAgeOfObjectsThatIAdvertiseToOthers, maximumAgeOfNodesThatIAdvertiseToOthers +from bitmessagemain import lengthOfTimeToLeaveObjectsInInventory, lengthOfTimeToHoldOnToAllPubkeys, maximumAgeOfAnObjectThatIAmWillingToAccept, maximumAgeOfObjectsThatIAdvertiseToOthers, maximumAgeOfNodesThatIAdvertiseToOthers,\ + neededPubkeys +import sys '''The singleCleaner class is a timer-driven thread that cleans data structures to free memory, resends messages when a remote node doesn't respond, and sends pong messages to keep connections alive if the network isn't busy. It cleans these data structures in memory: diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index 9e1582f9..e0d54c37 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -7,6 +7,9 @@ from addresses import * import bitmessagemain import highlevelcrypto import proofofwork +from bitmessagemain import neededPubkeys, encryptedBroadcastSwitchoverTime +import sys +from class_addressGenerator import pointMult # This thread, of which there is only one, does the heavy lifting: # calculating POWs. diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index f54d5a86..5848e868 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -4,6 +4,7 @@ import sqlite3 import time import shutil # used for moving the messages.dat file import sys +import os # This thread exists because SQLITE3 is so un-threadsafe that we must # submit queries to it and it puts results back in a different queue. They diff --git a/src/defaultKnownNodes.py b/src/defaultKnownNodes.py index 4f4e80ce..5c6d5b21 100644 --- a/src/defaultKnownNodes.py +++ b/src/defaultKnownNodes.py @@ -59,7 +59,7 @@ if __name__ == "__main__": APPNAME = "PyBitmessage" from os import path, environ if sys.platform == 'darwin': - from AppKit import NSSearchPathForDirectoriesInDomains + from AppKit import NSSearchPathForDirectoriesInDomains # @UnresolvedImport # http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSSearchPathForDirectoriesInDomains # NSApplicationSupportDirectory = 14 # NSUserDomainMask = 1 diff --git a/src/helper_generic.py b/src/helper_generic.py index 99c1c2d3..e79a5a43 100644 --- a/src/helper_generic.py +++ b/src/helper_generic.py @@ -1,4 +1,5 @@ import shared +import sys def convertIntToString(n): a = __builtins__.hex(n) diff --git a/src/helper_startup.py b/src/helper_startup.py index 3cea3a30..df27fd6e 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -8,7 +8,6 @@ storeConfigFilesInSameDirectoryAsProgramByDefault = False # The user may de-sel def loadConfig(): # First try to load the config file (the keys.dat file) from the program # directory - shared.config = ConfigParser.SafeConfigParser() shared.config.read('keys.dat') try: shared.config.get('bitmessagesettings', 'settingsversion') diff --git a/src/proofofwork.py b/src/proofofwork.py index f65c127f..f2c32c06 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -4,16 +4,17 @@ import hashlib from struct import unpack, pack import sys +from shared import config #import os def _set_idle(): if 'linux' in sys.platform: import os - os.nice(20) + os.nice(20) # @UndefinedVariable else: try: sys.getwindowsversion() - import win32api,win32process,win32con + import win32api,win32process,win32con # @UnresolvedImport pid = win32api.GetCurrentProcessId() handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid) win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS) diff --git a/src/shared.py b/src/shared.py index 256008c1..b225012c 100644 --- a/src/shared.py +++ b/src/shared.py @@ -8,7 +8,9 @@ import Queue import pickle import os import time +import ConfigParser +config = ConfigParser.SafeConfigParser() myECCryptorObjects = {} MyECSubscriptionCryptorObjects = {} myAddressesByHash = {} #The key in this dictionary is the RIPE hash which is encoded in an address and value is the address itself. diff --git a/src/singleton.py b/src/singleton.py index 7ecca3b7..ee5c3077 100644 --- a/src/singleton.py +++ b/src/singleton.py @@ -34,7 +34,7 @@ class singleinstance: print(e.errno) raise else: # non Windows - import fcntl + import fcntl # @UnresolvedImport self.fp = open(self.lockfile, 'w') try: fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB) @@ -53,7 +53,7 @@ class singleinstance: os.close(self.fd) os.unlink(self.lockfile) else: - import fcntl + import fcntl # @UnresolvedImport fcntl.lockf(self.fp, fcntl.LOCK_UN) if os.path.isfile(self.lockfile): os.unlink(self.lockfile)