Python bindings patches.

Uri Shachar Uri.Shachar at expand.com
Thu Jun 14 13:57:39 GMT 2007


I'm doing some maintenance work on the python bindings and I have the following patch - it fixes:

1) A bug in the spools.openprinter call.
2) Added "version" option to the getprinterdriver, and set the default to 3.
3) Changed description of the getprinterdriver method.

Regards,

	Uri
-------------- next part --------------
Index: python/setup.py
===================================================================
--- python/setup.py	(.../svn://svnanon.samba.org/samba/branches/SAMBA_3_0/source/python)	(revision 23495)
+++ python/setup.py	(.../python)	(working copy)
@@ -55,6 +55,14 @@
 next_is_path = 0
 next_is_flag = 0
 
+linker_flags = ['-pthread', '-rdynamic', '-pie', '-W', '-s']
+
+def is_prefix(s, prefix_list):
+    for prefix in prefix_list:
+        if s.startswith(prefix):
+            return True
+    return False
+
 for lib in string.split(samba_libs):
     if next_is_path != 0:
         library_dirs.append(lib);
@@ -63,18 +71,14 @@
         next_is_flag = 0;
     elif lib == "-Wl,-rpath":
         next_is_path = 1;
-    elif lib[0:2] == ("-l"):
+    elif lib.startswith("-l"):
         libraries.append(lib[2:])
-    elif lib[0:8] == ("-pthread"):
-        pass # Skip linker flags
-    elif lib[0:4] == ("-pie"):
-        pass # Skip linker flags
-    elif lib[0:2] == "-L":
+    elif lib.startswith("-L"):
         library_dirs.append(lib[2:])
-    elif lib[0:2] in ("-W","-s"):
+    elif is_prefix(lib, linker_flags):
         pass # Skip linker flags
-    elif lib[0:2] == "-z":
-        next_is_flag = 1 # Skip linker flags
+    elif lib.startswith("-z"):
+        next_is_flag = 1 # Skip the next linker flags
     else:
         print "Unknown entry '%s' in $LIBS variable passed to setup.py" % lib
         sys.exit(1)
Index: python/py_spoolss_drivers.c
===================================================================
--- python/py_spoolss_drivers.c	(.../svn://svnanon.samba.org/samba/branches/SAMBA_3_0/source/python)	(revision 23495)
+++ python/py_spoolss_drivers.c	(.../python)	(working copy)
@@ -171,13 +171,13 @@
 	PRINTER_DRIVER_CTR ctr;
 	int level = 1;
 	char *arch = "Windows NT x86";
-	int version = 2;
-	static char *kwlist[] = {"level", "arch", NULL};
+	int version = 3;
+	static char *kwlist[] = {"level", "arch", "version", NULL};
 
 	/* Parse parameters */
 
 	if (!PyArg_ParseTupleAndKeywords(
-		    args, kw, "|is", kwlist, &level, &arch))
+		    args, kw, "|isi", kwlist, &level, &arch, &version))
 		return NULL;
 
 	/* Call rpc function */
Index: python/py_spoolss_printers.c
===================================================================
--- python/py_spoolss_printers.c	(.../svn://svnanon.samba.org/samba/branches/SAMBA_3_0/source/python)	(revision 23495)
+++ python/py_spoolss_printers.c	(.../python)	(working copy)
@@ -77,7 +77,7 @@
 		goto done;
 	}
 
-	result = new_spoolss_policy_hnd_object(cli, mem_ctx, &hnd);
+	result = new_spoolss_policy_hnd_object(cli->pipe_list, mem_ctx, &hnd);
 
  done:
 	if (!result) {
Index: python/py_spoolss.c
===================================================================
--- python/py_spoolss.c	(.../svn://svnanon.samba.org/samba/branches/SAMBA_3_0/source/python)	(revision 23021)
+++ python/py_spoolss.c	(.../python)	(working copy)
@@ -176,11 +176,11 @@
 	/* Printer drivers */
 
 	{ "getprinterdriver", (PyCFunction)spoolss_hnd_getprinterdriver, 
-	  METH_VARARGS | METH_KEYWORDS, 
-	  "Return printer driver information.\n"
-"\n"
-"Return a dictionary of printer driver information for the printer driver\n"
-"bound to this printer."},
+	  METH_VARARGS | METH_KEYWORDS,
+	  "getprinterdriver([level [arch [version]]]) -> dictionary\n"
+      "\n"
+      "Return a dictionary of printer driver information for the printer driver\n"
+      "bound to this printer handle."},
 
 	/* Forms */
 


More information about the samba-technical mailing list