[tracker/gsettings-remaining-bits] functional-tests: python wrapper to access DConf



commit ee048f261906dae87b1f174aacd4590d4950a221
Author: Ivan Frade <ivan frade nokia com>
Date:   Mon Mar 21 09:53:28 2011 +0200

    functional-tests: python wrapper to access DConf
    
    Lame implementation until GI on dconf is available

 tests/functional-tests/common/utils/dconf.py |   41 ++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/tests/functional-tests/common/utils/dconf.py b/tests/functional-tests/common/utils/dconf.py
new file mode 100644
index 0000000..32d483a
--- /dev/null
+++ b/tests/functional-tests/common/utils/dconf.py
@@ -0,0 +1,41 @@
+import subprocess
+
+class DConfClient:
+    """
+    Shamefull implementation until we get GobjectIntrospection on libdconf
+    """
+    SCHEMA_MINER = "org.freedesktop.Tracker.Miner.FileSystem"
+    
+    def write (self, schema, key, value):
+        if (type(value) == int):
+            v = "i'%d'" % (value)
+        else:
+            v = value
+        command = ["gsettings", "set", schema, key, v]
+        print command
+        FNULL = open('/dev/null', 'w')
+        cmd = subprocess.Popen (command, stdout=subprocess.PIPE) #, stdout=FNULL, stderr=FNULL)
+        cmd.wait ()
+
+        
+    def read (self, schema, key):
+        command = ["gsettings", "get", schema, key]
+        FNULL = open('/dev/null', 'w')
+        cmd = subprocess.Popen (command, stdout=subprocess.PIPE) #, stdout=FNULL, stderr=FNULL)
+        return cmd.stdout.readline ()
+
+
+if __name__ == "__main__":
+
+    dconf = DConfClient ()
+    value = dconf.read (DConfClient.SCHEMA_MINER, "throttle")
+    print "Original value:", int (value)
+    print "Setting 5"
+    dconf.write (DConfClient.SCHEMA_MINER, "throttle", 5)
+    value = dconf.read (DConfClient.SCHEMA_MINER, "throttle")
+    print "Current value:", int (value)
+    print "Set 3"
+    dconf.write (DConfClient.SCHEMA_MINER, "throttle", 3)
+    value = dconf.read (DConfClient.SCHEMA_MINER, "throttle")
+    print "Current value:", int (value)
+        



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]