From b880e91997561ade02f40c6de9a70150a6e299fd Mon Sep 17 00:00:00 2001 From: surbhicis Date: Fri, 29 Oct 2021 13:08:11 +0530 Subject: [PATCH] recent changes --- desktop/icons/24x24/pybitmessage.png | Bin 0 -> 1852 bytes desktop/icons/scalable/pybitmessage.svg | 149 ++++++++++++++++++++++++ src/bitmessagemain.py | 6 + src/class_sqlThread.py | 2 + src/helper_sql.py | 6 + src/inventory.py | 6 +- src/main.py | 1 + src/network/__init__.py | 2 +- src/storage/filesystem.py | 9 +- src/storage/sqlite.py | 9 +- 10 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 desktop/icons/24x24/pybitmessage.png create mode 100644 desktop/icons/scalable/pybitmessage.svg diff --git a/desktop/icons/24x24/pybitmessage.png b/desktop/icons/24x24/pybitmessage.png new file mode 100644 index 0000000000000000000000000000000000000000..30f7313eb378b69c4e2f6cb66264c2ae678059e1 GIT binary patch literal 1852 zcmV-C2gCS@P)M^!E?E!Z`=4*Xy`ht_>fhjLl+eV_hy>=-Ek(A(EP8wh@6>5>i{Jah=UrfpOJpyyEE@4x%__we9`O^8Gz zY+YB^0D>Su5CjlH;N;0u?*~Bu&N&bS0ppzGa8EB4rY4DVPDBKSF-HCU16P-HEJ7j{ zNB_V8#>OVLvurL0*LBHtT@Xo}Jb4<4WQ?)(U)V^qv$OC6A8)<&J1DB6+N!HAqgS40M1-^F1`!DUX8C&gnRGe@ zugOKk3q#X23}v$zA1@%4ZpGc13}Zxu2iAXy3X>BMLSomhm+{n7Pk?idful#^*Ezyr z?^5Ynsk5uAtC7-^+n#tfol2v%r3J6O`Z`vx?m{NB3ZCb|_3ZsV_dC<+bR%^l!h!ug z@VU>%#>bmZoH+5fD_6!g$w1(jJD&Yfx-GS5)rys1j5Ug#pWXb-IOmw2o?hS6(|2Sf zpMOr0oWEy8bh}FcG{zVdMbZCv^7OGpGT!ZY?yDjYR4SFe34j4u5I6t=RaNovCkHF@ zoiaipD2jq)GP(ESrQv7p6jU1RJ^w~D8qrNF1lzV@nHGW|z_EWH$MA4|HvlM%F)+q3 zSF1lXI(qr%k!S>tSt5A%%qNy7fY#@OJ=EhAw1( z_N}dtZ{57*k%%G? zyxTA|2q7B+k`g<9wZry251!{C8jT8 z-p;x=cW;j;6M^e_Sar{;s;=ulO|_=rc^-)9w)un*3;rOYd80A9^_8lsC>CeFcKY<0 z4{lZ}Ry-a%wttgbW>)Wx=%_7={5wQBW?I>Bfy4Z=_PG=NJe~Q9lP@w~J_0!8!Mi z9zFhP-S^kT<8fHF3CFQv7zRw!gk#&#H626*-}f;&HHG}>D5{mY;+HpXy5F+Q%Xe-M z0U*X0G)+UPbnTIkKRHlVHEm6MdpjbL2t3b)X_;^w2d-^HS2Yk3s?{on^CK7@$wLGZ zp64ZohO$2d01W`9rl;?qQ0VgL*oRY7S08R~Z--+$Fw77_rVcY?z%ng_LLsP%0zrgw zxr|)yA}WL9CMO3t=b?@zi(yy>Of!T~C+VOB*94LhM2&|}VG20s7@sU4HnuD?>4oOphsFb>PI zZUf%`%U?g-yLaC=7-Oi_YVf%apL0|y71Zl>Y~1)DcJ6!;YuDTZB0_HPA}(DTUI=X2 zCW^)4PlABI9SVie+1UxpvTpCezI`9Hzx&R+{}~^jXqkryAs~c+loA9&&G%88o5S~i zunk+bJl6RAN16Z-N~LQLgR%WmN-SO4fpAk3q?Bk*BpZN(hk5|U(0jP|^`65=ej%iQ zs;ZDuEGZ;^06r_>FlqtwW!jai!%a;Br5)J=X qQ5iHQ#>b literal 0 HcmV?d00001 diff --git a/desktop/icons/scalable/pybitmessage.svg b/desktop/icons/scalable/pybitmessage.svg new file mode 100644 index 00000000..7c854e34 --- /dev/null +++ b/desktop/icons/scalable/pybitmessage.svg @@ -0,0 +1,149 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index dc7426ac..79228f14 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -30,6 +30,7 @@ import time import traceback import defaults +import helper_sql import shared import shutdown import state @@ -85,6 +86,7 @@ def signal_handler(signum, frame): class Main(object): """Main PyBitmessage class""" def start(self): + import pdb;pdb.set_trace() """Start main application""" # pylint: disable=too-many-statements,too-many-branches,too-many-locals fixSocket() @@ -197,8 +199,12 @@ class Main(object): # The closeEvent should command this thread to exit gracefully. sqlLookup.daemon = False sqlLookup.start() + print("Thread Started........................................... 200 in bitmessagemain.py") + helper_sql.sql_ready.wait() Inventory() # init + print("thread after inventory 204..................................",helper_sql.sql_available) + # init, needs to be early because other thread may access it early Dandelion() diff --git a/src/class_sqlThread.py b/src/class_sqlThread.py index d22ffadb..a7dd3048 100644 --- a/src/class_sqlThread.py +++ b/src/class_sqlThread.py @@ -35,7 +35,9 @@ class sqlThread(threading.Thread): def run(self): # pylint: disable=too-many-locals, too-many-branches, too-many-statements """Process SQL queries from `.helper_sql.sqlSubmitQueue`""" + print("line no 38 in class_Sqlthread......................................",helper_sql.sql_available) helper_sql.sql_available = True + print("run call in class_Sqlthread.py..................................",helper_sql.sql_available) self.conn = sqlite3.connect(state.appdata + 'messages.dat') self.conn.text_factory = str self.cur = self.conn.cursor() diff --git a/src/helper_sql.py b/src/helper_sql.py index cba98884..be665812 100644 --- a/src/helper_sql.py +++ b/src/helper_sql.py @@ -28,7 +28,9 @@ sqlReturnQueue = queue.Queue() sql_lock = threading.Lock() """ lock to prevent queueing a new request until the previous response is available """ +print("31...............................................................................before sql_available") sql_available = False +print("33................................................................................sql_available",sql_available) """set to True by `.threads.sqlThread` immediately upon start""" sql_ready = threading.Event() """set by `.threads.sqlThread` when ready for processing (after @@ -43,7 +45,11 @@ def sqlQuery(sql_statement, *args): :param list args: SQL query parameters :rtype: list """ + print('before asser throw............................................................................',sql_available) + print("sql_statementsql_statementsql_statementsql_statement before",sql_statement) assert sql_available + print('after asser throw............................................................................',sql_available) + print("sql_statementsql_statementsql_statementsql_statementsql_statementsql_statement after",sql_statement) sql_lock.acquire() sqlSubmitQueue.put(sql_statement) diff --git a/src/inventory.py b/src/inventory.py index fc06e455..4630e364 100644 --- a/src/inventory.py +++ b/src/inventory.py @@ -1,8 +1,8 @@ """The Inventory singleton""" # TODO make this dynamic, and watch out for frozen, like with messagetypes -import storage.filesystem -import storage.sqlite +import pybitmessage.storage.filesystem +import pybitmessage.storage.sqlite from bmconfigparser import BMConfigParser from singleton import Singleton @@ -16,7 +16,7 @@ class Inventory(): def __init__(self): self._moduleName = BMConfigParser().safeGet("inventory", "storage") self._inventoryClass = getattr( - getattr(storage, self._moduleName), + getattr(pybitmessage.storage, self._moduleName), "{}Inventory".format(self._moduleName.title()) ) self._realInventory = self._inventoryClass() diff --git a/src/main.py b/src/main.py index e1644436..40c314e7 100644 --- a/src/main.py +++ b/src/main.py @@ -1,6 +1,7 @@ """This module is for thread start.""" import state import sys +import pdb;pdb.set_trace() from bitmessagemain import main from termcolor import colored print(colored('kivy is not supported at the moment for this version..', 'red')) diff --git a/src/network/__init__.py b/src/network/__init__.py index 70613539..877fbece 100644 --- a/src/network/__init__.py +++ b/src/network/__init__.py @@ -1,7 +1,7 @@ """ Network subsystem packages """ -from addrthread import AddrThread +from pybitmessage.network.addrthread import AddrThread from announcethread import AnnounceThread from connectionpool import BMConnectionPool from dandelion import Dandelion diff --git a/src/storage/filesystem.py b/src/storage/filesystem.py index 150e8d9e..3425c00a 100644 --- a/src/storage/filesystem.py +++ b/src/storage/filesystem.py @@ -8,8 +8,8 @@ from binascii import hexlify, unhexlify from os import listdir, makedirs, path, remove, rmdir from threading import RLock -from paths import lookupAppdataFolder -from storage import InventoryItem, InventoryStorage +from pybitmessage.paths import lookupAppdataFolder +from pybitmessage.storage.storage import InventoryItem, InventoryStorage logger = logging.getLogger('default') @@ -239,7 +239,7 @@ class FilesystemInventory(InventoryStorage): def hashes_by_stream(self, stream): """Return inventory vectors (hashes) for a stream""" - try: + try: return self._inventory[stream].keys() except KeyError: return [] @@ -264,6 +264,7 @@ class FilesystemInventory(InventoryStorage): for streamDict in self._inventory.values(): for hashId, item in streamDict.items(): if item.expires < minTime: - deletes.append(hashId) + deletes.append(hashId) for hashId in deletes: self.delHashId(hashId) + \ No newline at end of file diff --git a/src/storage/sqlite.py b/src/storage/sqlite.py index 50a2034e..a5ae6a81 100644 --- a/src/storage/sqlite.py +++ b/src/storage/sqlite.py @@ -5,8 +5,8 @@ import sqlite3 import time from threading import RLock -from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery -from storage import InventoryItem, InventoryStorage +from pybitmessage.helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sql_ready +from pybitmessage.storage.storage import InventoryItem, InventoryStorage class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors @@ -90,6 +90,11 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors return values def unexpired_hashes_by_stream(self, stream): + # sql_ready.wait() + from threading import current_thread + print(current_thread().name,"Thread running....................................................") + + """Return unexpired inventory vectors filtered by stream""" with self.lock: t = int(time.time())