changing syntax for print lock
This commit is contained in:
parent
8760153f7f
commit
d747394234
|
@ -2,7 +2,7 @@
|
|||
|
||||
# Form implementation generated from reading ui file 'settings.ui'
|
||||
#
|
||||
# Created: Sat Jul 06 18:17:40 2013
|
||||
# Created: Sat Jul 06 18:24:20 2013
|
||||
# by: PyQt4 UI code generator 4.10.1
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
|
|
@ -9,9 +9,8 @@ class asyncoreThread(threading.Thread):
|
|||
threading.Thread.__init__(self)
|
||||
|
||||
def run(self):
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print "Asyncore thread started"
|
||||
shared.printLock.release()
|
||||
|
||||
while True:
|
||||
asyncore.loop(timeout=1) # Despite the horrible parameter name, this function will not timeout until all channels are closed.
|
||||
|
|
|
@ -104,11 +104,10 @@ class bitmessagePOP3Connection(asyncore.dispatcher):
|
|||
|
||||
def sendline(self, data, END=END):
|
||||
if self.debug:
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
sys.stdout.write("sending ")
|
||||
sys.stdout.write(data)
|
||||
sys.stdout.write("\n")
|
||||
shared.printLock.release()
|
||||
data = data + END
|
||||
while len(data) > 4096:
|
||||
self.send(data[:4096])
|
||||
|
@ -130,11 +129,10 @@ class bitmessagePOP3Connection(asyncore.dispatcher):
|
|||
self.data_buffer.append(chunk)
|
||||
|
||||
if self.debug:
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print('data_buffer', self.data_buffer)
|
||||
print('commands', self.commands)
|
||||
print('-')
|
||||
shared.printLock.release()
|
||||
|
||||
while len(self.commands):
|
||||
line = self.commands.popleft()
|
||||
|
@ -170,7 +168,7 @@ class bitmessagePOP3Connection(asyncore.dispatcher):
|
|||
|
||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(self.address)
|
||||
if status != 'success':
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print 'Error: Could not decode address: ' + self.address + ' : ' + status
|
||||
if status == 'checksumfailed':
|
||||
print 'Error: Checksum failed for address: ' + self.address
|
||||
|
@ -178,7 +176,6 @@ class bitmessagePOP3Connection(asyncore.dispatcher):
|
|||
print 'Error: Invalid characters in address: ' + self.address
|
||||
if status == 'versiontoohigh':
|
||||
print 'Error: Address version number too high (or zero) in address: ' + self.address
|
||||
shared.printLock.release()
|
||||
raise Exception("Invalid Bitmessage address: {}".format(self.address))
|
||||
|
||||
username = '{}@{}'.format(getBase58Capitaliation(self.address), self.address)
|
||||
|
@ -237,9 +234,8 @@ class bitmessagePOP3Connection(asyncore.dispatcher):
|
|||
msg = self.messages[index]
|
||||
content = self.getMessageContent(msg['msgid'])
|
||||
if self.debug:
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
sys.stdout.write(str(msg) + ": " + str(content))
|
||||
shared.printLock.release()
|
||||
yield "+OK {} octets".format(msg['size'])
|
||||
yield content['message']
|
||||
yield '.'
|
||||
|
@ -281,9 +277,8 @@ class bitmessagePOP3Server(asyncore.dispatcher):
|
|||
self.bind((bindAddress, pop3port))
|
||||
self.listen(10)
|
||||
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print "POP3 server started: SSL enabled={}".format(str(self.ssl))
|
||||
shared.printLock.release()
|
||||
|
||||
def handle_accept(self):
|
||||
sock, peer_address = self.accept()
|
||||
|
|
|
@ -179,7 +179,7 @@ class bitmessageSMTPChannel(asynchat.async_chat):
|
|||
|
||||
status, addressVersionNumber, streamNumber, ripe = decodeAddress(self.address)
|
||||
if status != 'success':
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print 'Error: Could not decode address: ' + self.address + ' : ' + status
|
||||
if status == 'checksumfailed':
|
||||
print 'Error: Checksum failed for address: ' + self.address
|
||||
|
@ -187,7 +187,6 @@ class bitmessageSMTPChannel(asynchat.async_chat):
|
|||
print 'Error: Invalid characters in address: ' + self.address
|
||||
if status == 'versiontoohigh':
|
||||
print 'Error: Address version number too high (or zero) in address: ' + self.address
|
||||
shared.printLock.release()
|
||||
raise Exception("Invalid Bitmessage address: {}".format(self.address))
|
||||
|
||||
self.fullUsername = '{}@{}'.format(getBase58Capitaliation(self.address), address)
|
||||
|
@ -324,9 +323,8 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
|
|||
bindAddress = '127.0.0.1'
|
||||
|
||||
smtpd.SMTPServer.__init__(self, (bindAddress, smtpport), None)
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print "SMTP server started: SSL enabled={}".format(str(self.ssl))
|
||||
shared.printLock.release()
|
||||
|
||||
def handle_accept(self):
|
||||
# Override SMTPServer's handle_accept so that we can start an SSL connection.
|
||||
|
@ -363,7 +361,7 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
|
|||
else:
|
||||
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(fromAddress)
|
||||
if status != 'success':
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print 'Error: Could not decode address: ' + fromAddress + ' : ' + status
|
||||
if status == 'checksumfailed':
|
||||
print 'Error: Checksum failed for address: ' + fromAddress
|
||||
|
@ -371,21 +369,18 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
|
|||
print 'Error: Invalid characters in address: ' + fromAddress
|
||||
if status == 'versiontoohigh':
|
||||
print 'Error: Address version number too high (or zero) in address: ' + fromAddress
|
||||
shared.printLock.release()
|
||||
raise Exception("Invalid Bitmessage address: {}".format(fromAddress))
|
||||
#fromAddress = addBMIfNotPresent(fromAddress) # I know there's a BM-, because it's required when using SMTP
|
||||
|
||||
try:
|
||||
fromAddressEnabled = shared.config.getboolean(fromAddress, 'enabled')
|
||||
except:
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print 'Error: Could not find your fromAddress in the keys.dat file.'
|
||||
shared.printLock.release()
|
||||
raise Exception("Could not find address in keys.dat: {}".format(fromAddress))
|
||||
if not fromAddressEnabled:
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print 'Error: Your fromAddress is disabled. Cannot send.'
|
||||
shared.printLock.release()
|
||||
raise Exception("The fromAddress is disabled: {}".format(fromAddress))
|
||||
|
||||
for recipient in rcpttos:
|
||||
|
@ -402,7 +397,7 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
|
|||
# into a utility func!
|
||||
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(toAddress)
|
||||
if status != 'success':
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print 'Error: Could not decode address: ' + toAddress + ' : ' + status
|
||||
if status == 'checksumfailed':
|
||||
print 'Error: Checksum failed for address: ' + toAddress
|
||||
|
@ -410,7 +405,6 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
|
|||
print 'Error: Invalid characters in address: ' + toAddress
|
||||
if status == 'versiontoohigh':
|
||||
print 'Error: Address version number too high (or zero) in address: ' + toAddress
|
||||
shared.printLock.release()
|
||||
raise Exception("Invalid Bitmessage address: {}".format(toAddress))
|
||||
|
||||
toAddressIsOK = False
|
||||
|
@ -423,9 +417,8 @@ class bitmessageSMTPServer(smtpd.SMTPServer):
|
|||
# The toAddress is one owned by me. We cannot send
|
||||
# messages to ourselves without significant changes
|
||||
# to the codebase.
|
||||
shared.printLock.acquire()
|
||||
with shared.printLock:
|
||||
print "Error: One of the addresses to which you are sending a message, {}, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.".format(toAddress)
|
||||
shared.printLock.release()
|
||||
raise Exception("An address that you are sending a message to, {}, is yours. Unfortunately the Bitmessage client cannot process its own messages. Please try running a second client on a different computer or within a VM.".format(toAddress))
|
||||
|
||||
# The subject is specially formatted to identify it from non-E-mail messages.
|
||||
|
|
Reference in New Issue
Block a user