Solved the pybitmessage -t issue and Removed unrequired prints and logger and typo

This commit is contained in:
jai.s 2020-09-17 19:59:00 +05:30
parent 550be6e4ec
commit 269ffbb275
No known key found for this signature in database
GPG Key ID: 360CFA25EFC67D12
7 changed files with 7 additions and 51 deletions

View File

@ -124,59 +124,40 @@ class singleAPI(StoppableThread):
errno.WSAEADDRINUSE = errno.EADDRINUSE
for attempt in range(50):
try:
print('+++++++++++++++++++++++127+++++++++++++++')
if attempt > 0:
print('+++++++++++++++++++++++128+++++++++++++++')
logger.warning(
'Failed to start API listener on port %s', port)
port = random.randint(32767, 65535)
print('+++++++++++++++++++++++133+++++++++++++++')
print('+++++++++++++++++++++++133+++++++++++++++')
se = StoppableXMLRPCServer(
(BMConfigParser().get(
'bitmessagesettings', 'apiinterface'),
port),
MySimpleXMLRPCRequestHandler, True, True)
print('+++++++++++++++++++++++140+++++++++++++++')
except socket.error as e:
print('+++++++++++++++++++++++142+++++++++++++++')
if e.errno in (errno.EADDRINUSE, errno.WSAEADDRINUSE):
print('+++++++++++++++++++++++144+++++++++++++++')
continue
else:
if attempt > 0:
print('+++++++++++++++++++++++148+++++++++++++++')
logger.warning('Setting apiport to %s', port)
BMConfigParser().set(
'bitmessagesettings', 'apiport', str(port))
BMConfigParser().save()
print('+++++++++++++++++++++++153+++++++++++++++')
break
print('+++++++++++++++++++++++156+++++++++++++++')
se.register_introspection_functions()
print('+++++++++++++++++++++++158+++++++++++++++')
apiNotifyPath = BMConfigParser().safeGet(
'bitmessagesettings', 'apinotifypath')
print('------------161-------------------')
if apiNotifyPath:
print('------------162-------------------')
logger.info('Trying to call %s', apiNotifyPath)
print('------------165-------------------')
try:
print('------------167-------------------')
subprocess.call([apiNotifyPath, "startingUp"])
except OSError:
print('------------170-------------------')
logger.warning(
'Failed to call %s, removing apinotifypath setting',
apiNotifyPath)
BMConfigParser().remove_option(
'bitmessagesettings', 'apinotifypath')
print('------------176-------------------')
se.serve_forever()
print('---------178------------------------')
class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
@ -199,9 +180,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
Note: this method is the same as in SimpleXMLRPCRequestHandler,
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
if not self.is_rpc_path_valid():
self.report_404()
@ -1513,10 +1491,6 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
def _dispatch(self, method, params):
# pylint: disable=attribute-defined-outside-init
self.cookies = []
print('111111111111111111111')
print('inside the _dispatch')
print('print the method name are -{}'.format(method))
print('1111111111111111111111')
validuser = self.APIAuthenticateClient()
if not validuser:
time.sleep(2)
@ -1525,13 +1499,10 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
try:
return self._handle_request(method, params)
except APIError as e:
print('except 11111111111111111111')
return str(e)
except varintDecodeError as e:
print('except 222222222222222222222')
logger.error(e)
return "API Error 0026: Data contains a malformed varint. Some details: %s" % e
except Exception as e:
print('except 333333333333333333333')
logger.exception(e)
return "API Error 0021: Unexpected API Failure - %s" % e

View File

@ -183,8 +183,6 @@ class Main(object):
adjustHalfOpenConnectionsLimit()
config = BMConfigParser()
daemon = config.safeGetBoolean('bitmessagesettings', 'daemon')
print('config.safeGetBoolean(bitmessagesettings' 'daemon)-{}'.format(
config.safeGetBoolean('bitmessagesettings', 'daemon')))
try:
opts, _ = getopt.getopt(
sys.argv[1:], "hcdt",
@ -249,7 +247,7 @@ class Main(object):
self.setSignalHandler()
set_thread_name("PyBitmessage")
set_thread_name("pybitmessage")
state.dandelion = config.safeGet('network', 'dandelion')
# dandelion requires outbound connections, without them,

View File

@ -22,7 +22,6 @@ class Inventory(object):
"""
def __init__(self):
self._moduleName = BMConfigParser().safeGet("inventory", "storage")
print('is I am called the Inventory')
self._inventoryClass = getattr(
getattr(storage, self._moduleName),
"{}Inventory".format(self._moduleName.title())

View File

@ -26,7 +26,7 @@ except ModuleNotFoundError:
from pybitmessage.queues import (
addressGeneratorQueue, objectProcessorQueue, UISignalQueue, workerQueue)
from pybitmessage.tests.test_process import TestProcessProto
def doCleanShutdown():
"""
Used to tell all the treads to finish work and exit.

View File

@ -45,9 +45,6 @@ class TestAPIShutdown(TestAPIProto, TestProcessShutdown):
self.assertEqual(self.api.shutdown(), 'done')
for _ in range(5):
if not self.process.is_running():
logger.info('-----------------------------------------')
logger.info('test_shutdown test_shutdown test_shutdown inside the break condition')
logger.info('-----------------------------------------')
break
time.sleep(2)
else:

View File

@ -8,6 +8,7 @@ from hashlib import sha256
from pybitmessage.pyelliptic.eccblind import ECCBlind
from pybitmessage.pyelliptic.eccblindchain import ECCBlindChain
from pybitmessage.pyelliptic.openssl import OpenSSL
from pybitmessage.debug import logger
# pylint: disable=protected-access
@ -30,7 +31,7 @@ class TestBlindSig(unittest.TestCase):
# only 64 byte messages are planned to be used in Bitmessage
msg = os.urandom(64)
msg_blinded = requester_obj.create_signing_request(point_r, msg)
self.assertEqual(len(msg_blinded), 32)
self.assertEqual(len(msg_blinded), 33)
# check
self.assertNotEqual(sha256(msg).digest(), msg_blinded)
@ -38,18 +39,18 @@ class TestBlindSig(unittest.TestCase):
# (3) Signature Generation
signature_blinded = signer_obj.blind_sign(msg_blinded)
assert isinstance(signature_blinded, bytes)
self.assertEqual(len(signature_blinded), 32)
self.assertEqual(len(signature_blinded), 33)
# (4) Extraction
signature = requester_obj.unblind(signature_blinded)
assert isinstance(signature, bytes)
self.assertEqual(len(signature), 65)
self.assertEqual(len(signature), 66)
self.assertNotEqual(signature, signature_blinded)
# (5) Verification
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):
"""Test our implementation of BN_is_odd"""

View File

@ -44,16 +44,6 @@ class TestProcessProto(unittest.TestCase):
time.sleep(5)
cls.pid = int(cls._get_readline('singleton.lock'))
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
def _get_readline(cls, pfile):