[tracker] functional-tests: Added a Python wrapper to access DConf
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] functional-tests: Added a Python wrapper to access DConf
- Date: Tue, 22 Mar 2011 16:01:21 +0000 (UTC)
commit 5415fef2888ad266964212991465ecc381142b81
Author: Ivan Frade <ivan frade nokia com>
Date: Mon Mar 21 09:53:28 2011 +0200
functional-tests: Added a Python wrapper to access DConf
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]