neardutils: Implement dump_all_records
authorSamuel Ortiz <sameo@linux.intel.com>
Sun, 10 Nov 2013 16:40:21 +0000 (17:40 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 10 Nov 2013 16:57:09 +0000 (17:57 +0100)
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
test/test-tag

index 64ef489..903e59e 100644 (file)
@@ -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)
index 6c28a70..5b0b1da 100755 (executable)
@@ -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()