From 3174c325913f724408d7dfa457162ddec71b347c Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Sun, 10 Nov 2013 17:40:21 +0100 Subject: [PATCH] neardutils: Implement dump_all_records This is useful for dumping all records from all tags, and avoids always having to specify a tag path on the test-tag command line. --- test/neardutils.py | 13 +++++++++++++ test/test-tag | 16 +++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/test/neardutils.py b/test/neardutils.py index 64ef489..903e59e 100644 --- a/test/neardutils.py +++ b/test/neardutils.py @@ -81,3 +81,16 @@ def dump_record(record_path): else: val = str(properties[key]) print " %s = %s" % (key, val) + +def dump_all_records(path): + bus = dbus.SystemBus() + om = dbus.Interface(bus.get_object("org.neard", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() + for path, interfaces in objects.iteritems(): + if "org.neard.Record" not in interfaces: + continue + + if path.startswith(path): + print(" [ %s ]" % (path)) + dump_record(path) diff --git a/test/test-tag b/test/test-tag index 6c28a70..5b0b1da 100755 --- a/test/test-tag +++ b/test/test-tag @@ -57,23 +57,21 @@ if (sys.argv[1] == "list"): if (sys.argv[1] == "dump"): if (len(sys.argv) < 3): - usage() - else: - tag_path = sys.argv[2] - om = dbus.Interface(bus.get_object("org.neard", "/"), "org.freedesktop.DBus.ObjectManager") objects = om.GetManagedObjects() for path, interfaces in objects.iteritems(): - if "org.neard.Record" not in interfaces: + if "org.neard.Tag" not in interfaces: continue - if path.startswith(tag_path): - print(" [ %s ]" % (path)) - neardutils.dump_record(path) + print("[ %s ]" % (path)) + neardutils.dump_all_records(path) sys.exit(0) + else: + neardutils.dump_all_records(sys.argv[2]) + sys.exit(0) if (sys.argv[1] == "write"): if (len(sys.argv) < 5): @@ -122,4 +120,4 @@ if (sys.argv[1] == "write"): usage() else: - usage() \ No newline at end of file + usage() -- 2.7.4