Solved the pybitmessage -t issue and Removed unrequired prints and logger and typo
This commit is contained in:
parent
550be6e4ec
commit
269ffbb275
29
src/api.py
29
src/api.py
|
@ -124,59 +124,40 @@ class singleAPI(StoppableThread):
|
||||||
errno.WSAEADDRINUSE = errno.EADDRINUSE
|
errno.WSAEADDRINUSE = errno.EADDRINUSE
|
||||||
for attempt in range(50):
|
for attempt in range(50):
|
||||||
try:
|
try:
|
||||||
print('+++++++++++++++++++++++127+++++++++++++++')
|
|
||||||
if attempt > 0:
|
if attempt > 0:
|
||||||
print('+++++++++++++++++++++++128+++++++++++++++')
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Failed to start API listener on port %s', port)
|
'Failed to start API listener on port %s', port)
|
||||||
port = random.randint(32767, 65535)
|
port = random.randint(32767, 65535)
|
||||||
print('+++++++++++++++++++++++133+++++++++++++++')
|
|
||||||
print('+++++++++++++++++++++++133+++++++++++++++')
|
|
||||||
se = StoppableXMLRPCServer(
|
se = StoppableXMLRPCServer(
|
||||||
(BMConfigParser().get(
|
(BMConfigParser().get(
|
||||||
'bitmessagesettings', 'apiinterface'),
|
'bitmessagesettings', 'apiinterface'),
|
||||||
port),
|
port),
|
||||||
MySimpleXMLRPCRequestHandler, True, True)
|
MySimpleXMLRPCRequestHandler, True, True)
|
||||||
print('+++++++++++++++++++++++140+++++++++++++++')
|
|
||||||
except socket.error as e:
|
except socket.error as e:
|
||||||
print('+++++++++++++++++++++++142+++++++++++++++')
|
|
||||||
if e.errno in (errno.EADDRINUSE, errno.WSAEADDRINUSE):
|
if e.errno in (errno.EADDRINUSE, errno.WSAEADDRINUSE):
|
||||||
print('+++++++++++++++++++++++144+++++++++++++++')
|
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
if attempt > 0:
|
if attempt > 0:
|
||||||
print('+++++++++++++++++++++++148+++++++++++++++')
|
|
||||||
logger.warning('Setting apiport to %s', port)
|
logger.warning('Setting apiport to %s', port)
|
||||||
BMConfigParser().set(
|
BMConfigParser().set(
|
||||||
'bitmessagesettings', 'apiport', str(port))
|
'bitmessagesettings', 'apiport', str(port))
|
||||||
BMConfigParser().save()
|
BMConfigParser().save()
|
||||||
print('+++++++++++++++++++++++153+++++++++++++++')
|
|
||||||
break
|
break
|
||||||
|
|
||||||
print('+++++++++++++++++++++++156+++++++++++++++')
|
|
||||||
se.register_introspection_functions()
|
se.register_introspection_functions()
|
||||||
print('+++++++++++++++++++++++158+++++++++++++++')
|
|
||||||
apiNotifyPath = BMConfigParser().safeGet(
|
apiNotifyPath = BMConfigParser().safeGet(
|
||||||
'bitmessagesettings', 'apinotifypath')
|
'bitmessagesettings', 'apinotifypath')
|
||||||
print('------------161-------------------')
|
|
||||||
if apiNotifyPath:
|
if apiNotifyPath:
|
||||||
print('------------162-------------------')
|
|
||||||
logger.info('Trying to call %s', apiNotifyPath)
|
logger.info('Trying to call %s', apiNotifyPath)
|
||||||
print('------------165-------------------')
|
|
||||||
try:
|
try:
|
||||||
print('------------167-------------------')
|
|
||||||
subprocess.call([apiNotifyPath, "startingUp"])
|
subprocess.call([apiNotifyPath, "startingUp"])
|
||||||
except OSError:
|
except OSError:
|
||||||
print('------------170-------------------')
|
|
||||||
logger.warning(
|
logger.warning(
|
||||||
'Failed to call %s, removing apinotifypath setting',
|
'Failed to call %s, removing apinotifypath setting',
|
||||||
apiNotifyPath)
|
apiNotifyPath)
|
||||||
BMConfigParser().remove_option(
|
BMConfigParser().remove_option(
|
||||||
'bitmessagesettings', 'apinotifypath')
|
'bitmessagesettings', 'apinotifypath')
|
||||||
print('------------176-------------------')
|
|
||||||
se.serve_forever()
|
se.serve_forever()
|
||||||
print('---------178------------------------')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
|
@ -199,9 +180,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
Note: this method is the same as in SimpleXMLRPCRequestHandler,
|
Note: this method is the same as in SimpleXMLRPCRequestHandler,
|
||||||
just hacked to handle cookies
|
just hacked to handle cookies
|
||||||
"""
|
"""
|
||||||
print('post post post post')
|
|
||||||
print('is this method are')
|
|
||||||
print('post post post post')
|
|
||||||
# Check that the path is legal
|
# Check that the path is legal
|
||||||
if not self.is_rpc_path_valid():
|
if not self.is_rpc_path_valid():
|
||||||
self.report_404()
|
self.report_404()
|
||||||
|
@ -1513,10 +1491,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
def _dispatch(self, method, params):
|
def _dispatch(self, method, params):
|
||||||
# pylint: disable=attribute-defined-outside-init
|
# pylint: disable=attribute-defined-outside-init
|
||||||
self.cookies = []
|
self.cookies = []
|
||||||
print('111111111111111111111')
|
|
||||||
print('inside the _dispatch')
|
|
||||||
print('print the method name are -{}'.format(method))
|
|
||||||
print('1111111111111111111111')
|
|
||||||
validuser = self.APIAuthenticateClient()
|
validuser = self.APIAuthenticateClient()
|
||||||
if not validuser:
|
if not validuser:
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
@ -1525,13 +1499,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
try:
|
try:
|
||||||
return self._handle_request(method, params)
|
return self._handle_request(method, params)
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
print('except 11111111111111111111')
|
|
||||||
return str(e)
|
return str(e)
|
||||||
except varintDecodeError as e:
|
except varintDecodeError as e:
|
||||||
print('except 222222222222222222222')
|
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
return "API Error 0026: Data contains a malformed varint. Some details: %s" % e
|
return "API Error 0026: Data contains a malformed varint. Some details: %s" % e
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('except 333333333333333333333')
|
|
||||||
logger.exception(e)
|
logger.exception(e)
|
||||||
return "API Error 0021: Unexpected API Failure - %s" % e
|
return "API Error 0021: Unexpected API Failure - %s" % e
|
||||||
|
|
|
@ -183,8 +183,6 @@ class Main(object):
|
||||||
adjustHalfOpenConnectionsLimit()
|
adjustHalfOpenConnectionsLimit()
|
||||||
config = BMConfigParser()
|
config = BMConfigParser()
|
||||||
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
|
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
|
||||||
print('config.safeGetBoolean(bitmessagesettings' 'daemon)-{}'.format(
|
|
||||||
config.safeGetBoolean('bitmessagesettings', 'daemon')))
|
|
||||||
try:
|
try:
|
||||||
opts, _ = getopt.getopt(
|
opts, _ = getopt.getopt(
|
||||||
sys.argv[1:], "hcdt",
|
sys.argv[1:], "hcdt",
|
||||||
|
@ -249,7 +247,7 @@ class Main(object):
|
||||||
|
|
||||||
self.setSignalHandler()
|
self.setSignalHandler()
|
||||||
|
|
||||||
set_thread_name("PyBitmessage")
|
set_thread_name("pybitmessage")
|
||||||
|
|
||||||
state.dandelion = config.safeGet('network', 'dandelion')
|
state.dandelion = config.safeGet('network', 'dandelion')
|
||||||
# dandelion requires outbound connections, without them,
|
# dandelion requires outbound connections, without them,
|
||||||
|
|
|
@ -22,7 +22,6 @@ class Inventory(object):
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._moduleName = BMConfigParser().safeGet("inventory", "storage")
|
self._moduleName = BMConfigParser().safeGet("inventory", "storage")
|
||||||
print('is I am called the Inventory')
|
|
||||||
self._inventoryClass = getattr(
|
self._inventoryClass = getattr(
|
||||||
getattr(storage, self._moduleName),
|
getattr(storage, self._moduleName),
|
||||||
"{}Inventory".format(self._moduleName.title())
|
"{}Inventory".format(self._moduleName.title())
|
||||||
|
|
|
@ -26,7 +26,7 @@ except ModuleNotFoundError:
|
||||||
from pybitmessage.queues import (
|
from pybitmessage.queues import (
|
||||||
addressGeneratorQueue, objectProcessorQueue, UISignalQueue, workerQueue)
|
addressGeneratorQueue, objectProcessorQueue, UISignalQueue, workerQueue)
|
||||||
|
|
||||||
from pybitmessage.tests.test_process import TestProcessProto
|
|
||||||
def doCleanShutdown():
|
def doCleanShutdown():
|
||||||
"""
|
"""
|
||||||
Used to tell all the treads to finish work and exit.
|
Used to tell all the treads to finish work and exit.
|
||||||
|
|
|
@ -45,9 +45,6 @@ class TestAPIShutdown(TestAPIProto, TestProcessShutdown):
|
||||||
self.assertEqual(self.api.shutdown(), 'done')
|
self.assertEqual(self.api.shutdown(), 'done')
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
if not self.process.is_running():
|
if not self.process.is_running():
|
||||||
logger.info('-----------------------------------------')
|
|
||||||
logger.info('test_shutdown test_shutdown test_shutdown inside the break condition')
|
|
||||||
logger.info('-----------------------------------------')
|
|
||||||
break
|
break
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -8,6 +8,7 @@ from hashlib import sha256
|
||||||
from pybitmessage.pyelliptic.eccblind import ECCBlind
|
from pybitmessage.pyelliptic.eccblind import ECCBlind
|
||||||
from pybitmessage.pyelliptic.eccblindchain import ECCBlindChain
|
from pybitmessage.pyelliptic.eccblindchain import ECCBlindChain
|
||||||
from pybitmessage.pyelliptic.openssl import OpenSSL
|
from pybitmessage.pyelliptic.openssl import OpenSSL
|
||||||
|
from pybitmessage.debug import logger
|
||||||
|
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class TestBlindSig(unittest.TestCase):
|
||||||
# only 64 byte messages are planned to be used in Bitmessage
|
# only 64 byte messages are planned to be used in Bitmessage
|
||||||
msg = os.urandom(64)
|
msg = os.urandom(64)
|
||||||
msg_blinded = requester_obj.create_signing_request(point_r, msg)
|
msg_blinded = requester_obj.create_signing_request(point_r, msg)
|
||||||
self.assertEqual(len(msg_blinded), 32)
|
self.assertEqual(len(msg_blinded), 33)
|
||||||
|
|
||||||
# check
|
# check
|
||||||
self.assertNotEqual(sha256(msg).digest(), msg_blinded)
|
self.assertNotEqual(sha256(msg).digest(), msg_blinded)
|
||||||
|
@ -38,18 +39,18 @@ class TestBlindSig(unittest.TestCase):
|
||||||
# (3) Signature Generation
|
# (3) Signature Generation
|
||||||
signature_blinded = signer_obj.blind_sign(msg_blinded)
|
signature_blinded = signer_obj.blind_sign(msg_blinded)
|
||||||
assert isinstance(signature_blinded, bytes)
|
assert isinstance(signature_blinded, bytes)
|
||||||
self.assertEqual(len(signature_blinded), 32)
|
self.assertEqual(len(signature_blinded), 33)
|
||||||
|
|
||||||
# (4) Extraction
|
# (4) Extraction
|
||||||
signature = requester_obj.unblind(signature_blinded)
|
signature = requester_obj.unblind(signature_blinded)
|
||||||
assert isinstance(signature, bytes)
|
assert isinstance(signature, bytes)
|
||||||
self.assertEqual(len(signature), 65)
|
self.assertEqual(len(signature), 66)
|
||||||
|
|
||||||
self.assertNotEqual(signature, signature_blinded)
|
self.assertNotEqual(signature, signature_blinded)
|
||||||
|
|
||||||
# (5) Verification
|
# (5) Verification
|
||||||
verifier_obj = ECCBlind(pubkey=signer_obj.pubkey())
|
verifier_obj = ECCBlind(pubkey=signer_obj.pubkey())
|
||||||
self.assertTrue(verifier_obj.verify(msg, signature))
|
self.assertTrue(verifier_obj.verify(msg, signature[1:]))
|
||||||
|
|
||||||
def test_is_odd(self):
|
def test_is_odd(self):
|
||||||
"""Test our implementation of BN_is_odd"""
|
"""Test our implementation of BN_is_odd"""
|
||||||
|
|
|
@ -44,17 +44,7 @@ class TestProcessProto(unittest.TestCase):
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
cls.pid = int(cls._get_readline('singleton.lock'))
|
cls.pid = int(cls._get_readline('singleton.lock'))
|
||||||
cls.process = psutil.Process(cls.pid)
|
cls.process = psutil.Process(cls.pid)
|
||||||
#comment
|
|
||||||
# logger.error('~~~$$$$$$$$^^^^&&&&&&&~~~')
|
|
||||||
# logger.info('cls.proccess_pid -{}'.format(
|
|
||||||
# cls.process.pid))
|
|
||||||
# logger.error('cls.proccess_name -{}'.format(
|
|
||||||
# cls.process.name))
|
|
||||||
# logger.error('cls.proccess_create_time -{}'.format(
|
|
||||||
# cls.process._create_time))
|
|
||||||
# logger.error('~~~$$$$$$$$^^^^&&&&&&&~~~')
|
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_readline(cls, pfile):
|
def _get_readline(cls, pfile):
|
||||||
pfile = os.path.join(cls.home, pfile)
|
pfile = os.path.join(cls.home, pfile)
|
||||||
|
|
Reference in New Issue
Block a user