]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
python: Don't hardcode LXCPATH in python module
authorStéphane Graber <stgraber@ubuntu.com>
Mon, 11 Mar 2013 15:57:50 +0000 (11:57 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 11 Mar 2013 16:19:30 +0000 (12:19 -0400)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
.gitignore
configure.ac
src/python-lxc/lxc.c
src/python-lxc/lxc/__init__.py [moved from src/python-lxc/lxc/__init__.py.in with 99% similarity]

index bef5cd1d180e2f7f64102abd9e8edebd3b45614d..26c97c810a261c29b15079f224fd037288ffe7b3 100644 (file)
@@ -66,7 +66,6 @@ src/lxc/lxc-wait
 src/lxc/legacy/lxc-ls
 
 src/python-lxc/build/
-src/python-lxc/lxc/__init__.py
 src/python-lxc/lxc/__pycache__/
 
 src/tests/lxc-test-containertests
index 792aae860abb351ec78a2bf6b06d75c95c37296d..9afb1482431cab07b824c552096788d9e955269c 100644 (file)
@@ -383,7 +383,6 @@ AC_CONFIG_FILES([
        src/lxc/lxc.functions
 
        src/python-lxc/Makefile
-       src/python-lxc/lxc/__init__.py
 
        src/lua-lxc/Makefile
 
index 2abdc4cc0036dc422191637683d4c5a3fcdc12d9..8fd0a78921410637ac92b74f45cac65453b77a03 100644 (file)
@@ -95,6 +95,12 @@ Container_init(Container *self, PyObject *args, PyObject *kwds)
     return 0;
 }
 
+static PyObject *
+get_default_config_path(Container *self, PyObject *args, PyObject *kwds)
+{
+    return PyUnicode_FromString(lxc_get_default_config_path());
+}
+
 // Container properties
 static PyObject *
 Container_config_file_name(Container *self, PyObject *args, PyObject *kwds)
@@ -628,12 +634,18 @@ PyVarObject_HEAD_INIT(NULL, 0)
     Container_new,                  /* tp_new */
 };
 
+static PyMethodDef LXC_methods[] = {
+    {"get_default_config_path",  (PyCFunction)get_default_config_path, METH_NOARGS,
+     "Returns the current LXC config path"},
+    {NULL, NULL, 0, NULL}
+};
+
 static PyModuleDef _lxcmodule = {
     PyModuleDef_HEAD_INIT,
     "_lxc",
     "Binding for liblxc in python",
     -1,
-    NULL, NULL, NULL, NULL, NULL
+    LXC_methods
 };
 
 PyMODINIT_FUNC
similarity index 99%
rename from src/python-lxc/lxc/__init__.py.in
rename to src/python-lxc/lxc/__init__.py
index f1848f24ae085edfeb4091f3b601aad45ca8ae37..828a1cb323fb1a8a7f8239f07dd8ce416ed48f13 100644 (file)
@@ -26,14 +26,13 @@ import glob
 import os
 import subprocess
 import stat
-import tempfile
 import time
 import warnings
 
 warnings.warn("The python-lxc API isn't yet stable "
               "and may change at any point in the future.", Warning, 2)
 
-default_config_path = "@LXCPATH@"
+default_config_path = _lxc.get_default_config_path()
 
 
 class ContainerNetwork():