2 Python wrappers for DCERPC/SMB client routines.
4 Copyright (C) Tim Potter, 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* Return a tuple of (error code, error string) from a WERROR */
26 PyObject *py_werror_tuple(WERROR werror)
28 return Py_BuildValue("is", W_ERROR_V(werror),
32 /* Return a tuple of (error code, error string) from a WERROR */
34 PyObject *py_ntstatus_tuple(NTSTATUS ntstatus)
36 return Py_BuildValue("is", NT_STATUS_V(ntstatus),
40 /* Initialise samba client routines */
42 static BOOL initialised;
44 void py_samba_init(void)
49 /* Load configuration file */
51 if (!lp_load(dyn_CONFIGFILE, True, False, False))
52 fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
54 /* Misc other stuff */
61 /* Debuglevel routines */
63 PyObject *get_debuglevel(PyObject *self, PyObject *args)
67 if (!PyArg_ParseTuple(args, ""))
70 debuglevel = PyInt_FromLong(DEBUGLEVEL);
75 PyObject *set_debuglevel(PyObject *self, PyObject *args)
79 if (!PyArg_ParseTuple(args, "i", &debuglevel))
82 DEBUGLEVEL = debuglevel;
88 /* Initialise logging */
90 PyObject *py_setup_logging(PyObject *self, PyObject *args, PyObject *kw)
92 BOOL interactive = False;
93 char *logfilename = NULL;
94 static char *kwlist[] = {"interactive", "logfilename", NULL};
96 if (!PyArg_ParseTupleAndKeywords(args, kw, "|is", kwlist,
97 &interactive, &logfilename))
100 if (interactive && logfilename) {
101 PyErr_SetString(PyExc_RuntimeError,
102 "can't be interactive and set log file name");
107 setup_logging("spoolss", True);
110 lp_set_logfile(logfilename);
111 setup_logging(logfilename, False);