[virt-tools-list] [RFC PATCH 06/10] tui: Hack in an 'import' blacklist

Cole Robinson crobinso at redhat.com
Mon Apr 18 18:06:48 UTC 2011


When we start sharing code between GUI and TUI, it will be easy to have
unwanted deps on gtk and gobject to sneak into the TUI code. Add fake
modules that override the offending imports and throw an easy to trackdown
exception.

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 src/virt-manager-tui.py.in                     |    2 +-
 src/virtManagerTui/importblacklist/gconf.py    |   21 +++++++++++++++++++++
 src/virtManagerTui/importblacklist/gobject.py  |   21 +++++++++++++++++++++
 src/virtManagerTui/importblacklist/gtk.py      |   21 +++++++++++++++++++++
 4 files changed, 64 insertions(+), 1 deletions(-)
 create mode 100644 src/virtManagerTui/importblacklist/__init__.py
 create mode 100644 src/virtManagerTui/importblacklist/gconf.py
 create mode 100644 src/virtManagerTui/importblacklist/gobject.py
 create mode 100644 src/virtManagerTui/importblacklist/gtk.py

diff --git a/src/virt-manager-tui.py.in b/src/virt-manager-tui.py.in
index 30f5a00..6a055fa 100644
--- a/src/virt-manager-tui.py.in
+++ b/src/virt-manager-tui.py.in
@@ -61,7 +61,7 @@ def setup_pypath():
     # First 2 hacks are to point python to local dir for source files in dev,
     # the third is the main path if you have  normal install
     if os.path.exists(os.getcwd() + "/src/virt-manager.py"):
-        pass
+        sys.path.insert(0, os.getcwd() + "/src/virtManagerTui/importblacklist")
     elif os.path.exists(os.getcwd() + "/build/src/virt-manager.py"):
         sys.path.insert(0, os.getcwd() + "/src")
     else:
diff --git a/src/virtManagerTui/importblacklist/__init__.py b/src/virtManagerTui/importblacklist/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/src/virtManagerTui/importblacklist/gconf.py b/src/virtManagerTui/importblacklist/gconf.py
new file mode 100644
index 0000000..477db7e
--- /dev/null
+++ b/src/virtManagerTui/importblacklist/gconf.py
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011 Cole Robinson <crobinso at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+#
+
+raise RuntimeError("TUI cannot import gconf")
diff --git a/src/virtManagerTui/importblacklist/gobject.py b/src/virtManagerTui/importblacklist/gobject.py
new file mode 100644
index 0000000..eebae65
--- /dev/null
+++ b/src/virtManagerTui/importblacklist/gobject.py
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011 Cole Robinson <crobinso at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+#
+
+raise RuntimeError("TUI cannot import gobject")
diff --git a/src/virtManagerTui/importblacklist/gtk.py b/src/virtManagerTui/importblacklist/gtk.py
new file mode 100644
index 0000000..aa1275c
--- /dev/null
+++ b/src/virtManagerTui/importblacklist/gtk.py
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2011 Red Hat, Inc.
+# Copyright (C) 2011 Cole Robinson <crobinso at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA.
+#
+
+raise RuntimeError("TUI cannot import GTK")
-- 
1.7.4




More information about the virt-tools-list mailing list