@@ -113,6 +113,14 @@ def main():
with lock:
pbar.update()
+ def handle_remove(args, client):
+ where = {k: v for k, v in args.where}
+ if where:
+ result = client.remove(where)
+ print("Removed %d row(s)" % (result["count"]))
+ else:
+ print("No query specified")
+
parser = argparse.ArgumentParser(description='Hash Equivalence Client')
parser.add_argument('--address', default=DEFAULT_ADDRESS, help='Server address (default "%(default)s")')
parser.add_argument('--log', default='WARNING', help='Set logging level')
@@ -137,6 +145,11 @@ def main():
help='Include string in outhash')
stress_parser.set_defaults(func=handle_stress)
+ remove_parser = subparsers.add_parser('remove', help="Remove hash entries")
+ remove_parser.add_argument("--where", "-w", metavar="KEY VALUE", nargs=2, action="append", default=[],
+ help="Remove entries from table where KEY == VALUE")
+ remove_parser.set_defaults(func=handle_remove)
+
args = parser.parse_args()
logger = logging.getLogger('hashserv')
@@ -516,13 +516,17 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
query = ('DELETE FROM %s WHERE ' % table_name) + ' AND '.join("%s=:%s" % (k, k) for k in where.keys())
print(query)
cursor.execute(query, where)
+ return cursor.rowcount
+ return 0
+
+ count = 0
with closing(self.db.cursor()) as cursor:
- do_remove(OUTHASH_TABLE_COLUMNS, "outhashes_v2", cursor)
- do_remove(UNIHASH_TABLE_COLUMNS, "unihashes_v2", cursor)
+ count += do_remove(OUTHASH_TABLE_COLUMNS, "outhashes_v2", cursor)
+ count += do_remove(UNIHASH_TABLE_COLUMNS, "unihashes_v2", cursor)
self.db.commit()
- self.write_message({})
+ self.write_message({"count": count})
def query_equivalent(self, cursor, method, taskhash):
# This is part of the inner loop and must be as fast as possible
Adds a subcommand to invoke the remove API on the server [YOCTO #15064] Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> --- bitbake/bin/bitbake-hashclient | 13 +++++++++++++ bitbake/lib/hashserv/server.py | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-)