1 /* libguestfs python bindings
2 * Copyright (C) 2009-2011 Red Hat Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 /* This file contains a small number of functions that are written by
20 * hand. The majority of the bindings are generated (see
30 #include "guestfs-py.h"
33 py_guestfs_create (PyObject *self, PyObject *args)
37 g = guestfs_create ();
39 PyErr_SetString (PyExc_RuntimeError,
40 "guestfs.create: failed to allocate handle");
43 guestfs_set_error_handler (g, NULL, NULL);
44 /* This can return NULL, but in that case put_handle will have
45 * set the Python error string.
47 return put_handle (g);
51 py_guestfs_close (PyObject *self, PyObject *args)
53 PyThreadState *py_save = NULL;
57 if (!PyArg_ParseTuple (args, (char *) "O:guestfs_close", &py_g))
59 g = get_handle (py_g);
61 if (PyEval_ThreadsInitialized ())
62 py_save = PyEval_SaveThread ();
64 if (PyEval_ThreadsInitialized ())
65 PyEval_RestoreThread (py_save);