bitmessagemain, changing prints tologger functions
This commit is contained in:
parent
db31cb4147
commit
0f357529ed
|
@ -34,11 +34,13 @@ from class_addressGenerator import *
|
||||||
# Helper Functions
|
# Helper Functions
|
||||||
import helper_bootstrap
|
import helper_bootstrap
|
||||||
|
|
||||||
|
# Debug logger
|
||||||
|
from debug import logger
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.platform == 'darwin':
|
if sys.platform == 'darwin':
|
||||||
if float("{1}.{2}".format(*sys.version_info)) < 7.5:
|
if float("{1}.{2}".format(*sys.version_info)) < 7.5:
|
||||||
print "You should use python 2.7.5 or greater."
|
logger.critical("You should use python 2.7.5 or greater. Your version: {0}.{1}.{2}".format(*sys.version_info))
|
||||||
print "Your version: {0}.{1}.{2}".format(*sys.version_info)
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def connectToStream(streamNumber):
|
def connectToStream(streamNumber):
|
||||||
|
@ -126,7 +128,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
print 'Authentication failed because header lacks Authentication field'
|
logger.warn('Authentication failed because header lacks Authentication field')
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -276,7 +278,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
if numberOfAddresses > 999:
|
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.'
|
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()
|
shared.apiAddressGeneratorReturnQueue.queue.clear()
|
||||||
print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.'
|
logger.debug('Requesting that the addressGenerator create', numberOfAddresses, 'addresses.')
|
||||||
shared.addressGeneratorQueue.put(
|
shared.addressGeneratorQueue.put(
|
||||||
('createDeterministicAddresses', addressVersionNumber, streamNumber,
|
('createDeterministicAddresses', addressVersionNumber, streamNumber,
|
||||||
'unused API address', numberOfAddresses, passphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes))
|
'unused API address', numberOfAddresses, passphrase, eighteenByteRipe, nonceTrialsPerByte, payloadLengthExtraBytes))
|
||||||
|
@ -302,7 +304,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
if streamNumber != 1:
|
if streamNumber != 1:
|
||||||
return 'API Error 0003: The stream number must be 1. Others aren\'t supported.'
|
return 'API Error 0003: The stream number must be 1. Others aren\'t supported.'
|
||||||
shared.apiAddressGeneratorReturnQueue.queue.clear()
|
shared.apiAddressGeneratorReturnQueue.queue.clear()
|
||||||
print 'Requesting that the addressGenerator create', numberOfAddresses, 'addresses.'
|
logger.debug('Requesting that the addressGenerator create', numberOfAddresses, 'addresses.')
|
||||||
shared.addressGeneratorQueue.put(
|
shared.addressGeneratorQueue.put(
|
||||||
('getDeterministicAddress', addressVersionNumber,
|
('getDeterministicAddress', addressVersionNumber,
|
||||||
streamNumber, 'unused API address', numberOfAddresses, passphrase, eighteenByteRipe))
|
streamNumber, 'unused API address', numberOfAddresses, passphrase, eighteenByteRipe))
|
||||||
|
@ -515,8 +517,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(
|
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(
|
||||||
toAddress)
|
toAddress)
|
||||||
if status != 'success':
|
if status != 'success':
|
||||||
with shared.printLock:
|
logger.warn('API Error 0007: Could not decode address:', toAddress, ':', status)
|
||||||
print 'API Error 0007: Could not decode address:', toAddress, ':', status
|
|
||||||
|
|
||||||
if status == 'checksumfailed':
|
if status == 'checksumfailed':
|
||||||
return 'API Error 0008: Checksum failed for address: ' + toAddress
|
return 'API Error 0008: Checksum failed for address: ' + toAddress
|
||||||
|
@ -532,8 +533,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(
|
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(
|
||||||
fromAddress)
|
fromAddress)
|
||||||
if status != 'success':
|
if status != 'success':
|
||||||
with shared.printLock:
|
logger.warn('API Error 0007: Could not decode address:', fromAddress, ':', status)
|
||||||
print 'API Error 0007: Could not decode address:', fromAddress, ':', status
|
|
||||||
|
|
||||||
if status == 'checksumfailed':
|
if status == 'checksumfailed':
|
||||||
return 'API Error 0008: Checksum failed for address: ' + fromAddress
|
return 'API Error 0008: Checksum failed for address: ' + fromAddress
|
||||||
|
@ -597,8 +597,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(
|
status, addressVersionNumber, streamNumber, fromRipe = decodeAddress(
|
||||||
fromAddress)
|
fromAddress)
|
||||||
if status != 'success':
|
if status != 'success':
|
||||||
with shared.printLock:
|
logger.warn('API Error 0007: Could not decode address:', fromAddress, ':', status)
|
||||||
print 'API Error 0007: Could not decode address:', fromAddress, ':', status
|
|
||||||
|
|
||||||
if status == 'checksumfailed':
|
if status == 'checksumfailed':
|
||||||
return 'API Error 0008: Checksum failed for address: ' + fromAddress
|
return 'API Error 0008: Checksum failed for address: ' + fromAddress
|
||||||
|
@ -668,8 +667,7 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(
|
status, addressVersionNumber, streamNumber, toRipe = decodeAddress(
|
||||||
address)
|
address)
|
||||||
if status != 'success':
|
if status != 'success':
|
||||||
with shared.printLock:
|
logger.warn('API Error 0007: Could not decode address:', address, ':', status)
|
||||||
print 'API Error 0007: Could not decode address:', address, ':', status
|
|
||||||
|
|
||||||
if status == 'checksumfailed':
|
if status == 'checksumfailed':
|
||||||
return 'API Error 0008: Checksum failed for address: ' + address
|
return 'API Error 0008: Checksum failed for address: ' + address
|
||||||
|
@ -808,8 +806,7 @@ if __name__ == "__main__":
|
||||||
except:
|
except:
|
||||||
apiNotifyPath = ''
|
apiNotifyPath = ''
|
||||||
if apiNotifyPath != '':
|
if apiNotifyPath != '':
|
||||||
with shared.printLock:
|
logger.debug('Trying to call', apiNotifyPath)
|
||||||
print 'Trying to call', apiNotifyPath
|
|
||||||
|
|
||||||
call([apiNotifyPath, "startingUp"])
|
call([apiNotifyPath, "startingUp"])
|
||||||
singleAPIThread = singleAPI()
|
singleAPIThread = singleAPI()
|
||||||
|
@ -827,16 +824,15 @@ if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
except Exception as err:
|
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'
|
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')
|
||||||
print 'Error message:', err
|
logger.error('Error message: '+ err)
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
||||||
import bitmessageqt
|
import bitmessageqt
|
||||||
bitmessageqt.run()
|
bitmessageqt.run()
|
||||||
else:
|
else:
|
||||||
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
shared.config.remove_option('bitmessagesettings', 'dontconnect')
|
||||||
with shared.printLock:
|
logger.info('Running as a daemon. You can use Ctrl+C to exit.')
|
||||||
print 'Running as a daemon. You can use Ctrl+C to exit.'
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(20)
|
time.sleep(20)
|
||||||
|
|
Reference in New Issue
Block a user