summaryrefslogtreecommitdiff
path: root/source4/scripting/bin/winreg.py
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2007-12-23 19:19:41 -0600
committerStefan Metzmacher <metze@samba.org>2007-12-24 01:51:03 -0600
commitaa0a06f13c44e0eca0b3f2f0c34f0f7995b87159 (patch)
tree92c180a6928f94f64934e2fab842768c134fed63 /source4/scripting/bin/winreg.py
parent784c22899f211fa42728e784c2f2e6e5701ddcac (diff)
downloadsamba-aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159.tar.gz
samba-aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159.tar.bz2
samba-aa0a06f13c44e0eca0b3f2f0c34f0f7995b87159.zip
r26570: - Trim size of the swig-generated Python bindings by removing a bunch of {}'s.
- Start working on Python equivalents for various EJS tests. - Fix regression in argument order for reg_diff_apply() in EJS bindings. (This used to be commit c550c03372cb260b78f6a6c132e70571bc4cb852)
Diffstat (limited to 'source4/scripting/bin/winreg.py')
-rw-r--r--source4/scripting/bin/winreg.py93
1 files changed, 93 insertions, 0 deletions
diff --git a/source4/scripting/bin/winreg.py b/source4/scripting/bin/winreg.py
new file mode 100644
index 0000000000..6cdc3a5898
--- /dev/null
+++ b/source4/scripting/bin/winreg.py
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+#
+# tool to manipulate a remote registry
+# Copyright Andrew Tridgell 2005
+# Copyright Jelmer Vernooij 2007
+# Released under the GNU GPL v3 or later
+#
+
+import sys
+
+options = GetOptions(ARGV,
+ "POPT_AUTOHELP",
+ "POPT_COMMON_SAMBA",
+ "POPT_COMMON_CREDENTIALS",
+ "createkey=s")
+if (options == undefined) {
+ print "Failed to parse options"
+ sys.exit(-1)
+
+if len(sys.argv < 2:
+ print "Usage: %s <BINDING> [path]" % sys.argv[0]
+ sys.exit(-1)
+
+binding = options.ARGV[0]
+reg = winregObj()
+
+print "Connecting to " + binding
+status = reg.connect(binding)
+if (status.is_ok != true) {
+ print("Failed to connect to " + binding + " - " + status.errstr + "\n")
+ return -1
+}
+
+def list_values(path):
+ list = reg.enum_values(path)
+ if (list == undefined) {
+ return
+ }
+ for (i=0;i<list.length;i++) {
+ v = list[i]
+ printf("\ttype=%-30s size=%4d '%s'\n", reg.typestring(v.type), v.size, v.name)
+ if (v.type == reg.REG_SZ || v.type == reg.REG_EXPAND_SZ) {
+ printf("\t\t'%s'\n", v.value)
+ }
+ if (v.type == reg.REG_MULTI_SZ) {
+ for (j in v.value) {
+ printf("\t\t'%s'\n", v.value[j])
+ }
+ }
+ if (v.type == reg.REG_DWORD || v.type == reg.REG_DWORD_BIG_ENDIAN) {
+ printf("\t\t0x%08x (%d)\n", v.value, v.value)
+ }
+ if (v.type == reg.REG_QWORD) {
+ printf("\t\t0x%llx (%lld)\n", v.value, v.value)
+ }
+ }
+
+def list_path(path):
+ count = 0
+ list = reg.enum_path(path)
+ if (list == undefined) {
+ println("Unable to list " + path)
+ return 0
+ }
+ list_values(path)
+ count = count + list.length
+ for (i=0;i<list.length;i++) {
+ if (path) {
+ npath = path + "\\" + list[i]
+ } else {
+ npath = list[i]
+ }
+ println(npath)
+ count = count + list_path(npath)
+ }
+ return count
+
+if len(sys.argv) > 2:
+ root = sys.argv[2]
+else:
+ root = ''
+
+if options.createkey:
+ try:
+ reg.create_key("HKLM\\SOFTWARE", options.createkey)
+ except:
+ print "Failed to create key"
+else:
+ printf("Listing registry tree '%s'\n", root)
+ count = list_path(root)
+ if count == 0:
+ println("No entries found")
+ sys.exit(1)