bitmessagemain, changing prints tologger functions

This commit is contained in:
Jordan Hall 2013-08-06 22:28:21 +01:00
parent db31cb4147
commit 0f357529ed
1 changed files with 15 additions and 19 deletions

View File

@ -34,11 +34,13 @@ from class_addressGenerator import *
# Helper Functions
import helper_bootstrap
# Debug logger
from debug import logger
import sys
if sys.platform == 'darwin':
if float("{1}.{2}".format(*sys.version_info)) < 7.5:
print "You should use python 2.7.5 or greater."
print "Your version: {0}.{1}.{2}".format(*sys.version_info)
logger.critical("You should use python 2.7.5 or greater. Your version: {0}.{1}.{2}".format(*sys.version_info))
sys.exit(0)
def connectToStream(streamNumber):
@ -126,7 +128,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
else:
return False
else:
print 'Authentication failed because header lacks Authentication field'
logger.warn('Authentication failed because header lacks Authentication field')
time.sleep(2)
return False
@ -276,7 +278,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
if numberOfAddresses > 999:
return 'API Error 0005: You have (accidentally?) specified too many addresses to make. Maximum 999. This check only exists to prevent mischief; if you really want to create more addresses than this, contact the Bitmessage developers and we can modify the check or you can do it yourself by searching the source code for this message.'
shared.apiAddressGeneratorReturnQueue.queue.clear()
print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.'
logger.debug('Requesting that the addressGenerator create', numberOfAddresses, 'addresses.')
shared.addressGeneratorQueue.put(
('createDeterministicAddresses', addressVersionNumber, streamNumber,
'unused API address', numberOfAddresses, passphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes))
@ -302,7 +304,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
if streamNumber != 1:
return 'API Error 0003: The stream number must be 1. Others aren\'t supported.'
shared.apiAddressGeneratorReturnQueue.queue.clear()
print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.'
logger.debug('Requesting that the addressGenerator create', numberOfAddresses, 'addresses.')
shared.addressGeneratorQueue.put(
('getDeterministicAddress', addressVersionNumber,
streamNumber, 'unused API address', numberOfAddresses, passphrase, eighteenByteRipe))
@ -515,8 +517,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(
toAddress)
if status != 'success':
with shared.printLock:
print 'API Error 0007: Could not decode address:', toAddress, ':', status
logger.warn('API Error 0007: Could not decode address:', toAddress, ':', status)
if status == 'checksumfailed':
return 'API Error 0008: Checksum failed for address: ' + toAddress
@ -532,8 +533,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(
fromAddress)
if status != 'success':
with shared.printLock:
print 'API Error 0007: Could not decode address:', fromAddress, ':', status
logger.warn('API Error 0007: Could not decode address:', fromAddress, ':', status)
if status == 'checksumfailed':
return 'API Error 0008: Checksum failed for address: ' + fromAddress
@ -597,8 +597,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(
fromAddress)
if status != 'success':
with shared.printLock:
print 'API Error 0007: Could not decode address:', fromAddress, ':', status
logger.warn('API Error 0007: Could not decode address:', fromAddress, ':', status)
if status == 'checksumfailed':
return 'API Error 0008: Checksum failed for address: ' + fromAddress
@ -668,8 +667,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(
address)
if status != 'success':
with shared.printLock:
print 'API Error 0007: Could not decode address:', address, ':', status
logger.warn('API Error 0007: Could not decode address:', address, ':', status)
if status == 'checksumfailed':
return 'API Error 0008: Checksum failed for address: ' + address
@ -808,8 +806,7 @@ if __name__ == "__main__":
except:
apiNotifyPath = ''
if apiNotifyPath != '':
with shared.printLock:
print 'Trying to call', apiNotifyPath
logger.debug('Trying to call', apiNotifyPath)
call([apiNotifyPath, "startingUp"])
singleAPIThread = singleAPI()
@ -827,16 +824,15 @@ if __name__ == "__main__":
try:
from PyQt4 import QtCore, QtGui
except Exception as err:
print 'PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon'
print 'Error message:', err
logger.error('PyBitmessage requires PyQt unless you want to run it as a daemon and interact with it using the API. You can download PyQt from http://www.riverbankcomputing.com/software/pyqt/download or by searching Google for \'PyQt Download\'. If you want to run in daemon mode, see https://bitmessage.org/wiki/Daemon')
logger.error('Error message: '+ err)
os._exit(0)
import bitmessageqt
bitmessageqt.run()
else:
shared.config.remove_option('bitmessagesettings', 'dontconnect')
with shared.printLock:
print 'Running as a daemon. You can use Ctrl+C to exit.'
logger.info('Running as a daemon. You can use Ctrl+C to exit.')
while True:
time.sleep(20)