Skip to content

Commit

Permalink
Added a number of missing imports fixing several issues (thank you Py…
Browse files Browse the repository at this point in the history
…Dev)
  • Loading branch information
DivineOmega committed Jun 23, 2013
1 parent e9dc2d5 commit 2eb6558
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
**.DS_Store
src/build
src/dist
src/.project
src/.pydevprojecy
2 changes: 1 addition & 1 deletion src/build_osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

import sys, os, shutil, re
from setuptools import setup
from setuptools import setup # @UnresolvedImport


name = "Bitmessage"
Expand Down
2 changes: 2 additions & 0 deletions src/class_addressGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
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

Expand Down
2 changes: 1 addition & 1 deletion src/class_outgoingSynSender.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def run(self):
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
Expand Down
19 changes: 13 additions & 6 deletions src/class_receiveDataThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,16 @@
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

Expand Down Expand Up @@ -814,8 +821,8 @@ def processmsg(self, readPosition, encryptedData):
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()
Expand Down Expand Up @@ -1046,7 +1053,7 @@ def processmsg(self, readPosition, encryptedData):
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(
Expand All @@ -1069,14 +1076,14 @@ def processmsg(self, readPosition, encryptedData):
# 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):
Expand Down
3 changes: 3 additions & 0 deletions src/class_sendDataThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import Queue
from struct import unpack, pack
import hashlib
import random
import sys
import socket

import bitmessagemain

Expand Down
4 changes: 3 additions & 1 deletion src/class_singleCleaner.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/class_singleWorker.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
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.
Expand Down
1 change: 1 addition & 0 deletions src/class_sqlThread.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion src/defaultKnownNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def readDefaultKnownNodes(appdata):
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
Expand Down
1 change: 1 addition & 0 deletions src/helper_generic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shared
import sys

def convertIntToString(n):
a = __builtins__.hex(n)
Expand Down
1 change: 0 additions & 1 deletion src/helper_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
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')
Expand Down
5 changes: 3 additions & 2 deletions src/proofofwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
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.
Expand Down
4 changes: 2 additions & 2 deletions src/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, flavor_id=""):
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)
Expand All @@ -53,7 +53,7 @@ def __del__(self):
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)
Expand Down

0 comments on commit 2eb6558

Please sign in to comment.