gnome-games r7677 - in trunk/glchess: . src src/lib
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r7677 - in trunk/glchess: . src src/lib
- Date: Fri, 30 May 2008 00:18:44 +0000 (UTC)
Author: rancell
Date: Fri May 30 00:18:43 2008
New Revision: 7677
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7677&view=rev
Log:
Fix sys.path problems
Modified:
trunk/glchess/ChangeLog
trunk/glchess/src/glchess.in.in
trunk/glchess/src/lib/defaults.py.in
Modified: trunk/glchess/src/glchess.in.in
==============================================================================
--- trunk/glchess/src/glchess.in.in (original)
+++ trunk/glchess/src/glchess.in.in Fri May 30 00:18:43 2008
@@ -8,6 +8,9 @@
# software under the terms of the GNU General Public License,
# version 2 or later.
+import sys
+import os
+
# Some version of PyGTK require this to be called before importing the gtk module
import pygtk
pygtk.require('2.0')
@@ -20,39 +23,31 @@
#No bugbuddy support
pass
-import sys
-installed_mode = True
+# Chek if we are installed
+root_dir = os.path.dirname(__file__)
+if os.path.exists(os.path.join(root_dir, 'Makefile.am')):
+ sys.path.insert(0, os.path.abspath(root_dir))
+ import lib
+ sys.modules['glchess'] = sys.modules['lib']
try:
- # Import glchess module from source distribution.
- import lib;
- sys.modules["glchess"] = sys.modules["lib"];
+ # Import glChess from pyexecdir or system installation.
from glchess.glchess import start_game
- installed_mode = False
-
except ImportError:
- try:
- # Import glChess from pyexecdir or system installation.
- installed_mode = True
- from glchess.glchess import start_game
-
- except ImportError:
- # Import of glChess failed. Show error message.
- import gtk
- import os.path
- import gettext
- from gettext import gettext as _
+ # Import of glChess failed. Show error message.
+ import gtk
+ import os.path
+ import gettext
+ from gettext import gettext as _
- gettext.bindtextdomain('gnome-games', os.path.join('@prefix@', 'share', 'locale'))
- gettext.textdomain('gnome-games')
- title = _("Chess incorrectly installed")
- description = _("""Chess is not able to start because required application files are not installed. If you are currently upgrading your system please wait until the upgrade has completed.""")
- dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
- dialog.format_secondary_text(description)
- dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
- dialog.run()
- sys.exit(0)
-
-sys.modules["glchess"].installed_mode = installed_mode
+ gettext.bindtextdomain('gnome-games', os.path.join('@prefix@', 'share', 'locale'))
+ gettext.textdomain('gnome-games')
+ title = _("Chess incorrectly installed")
+ description = _("""Chess is not able to start because required application files are not installed. If you are currently upgrading your system please wait until the upgrade has completed.""")
+ dialog = gtk.MessageDialog(type = gtk.MESSAGE_ERROR, message_format = title)
+ dialog.format_secondary_text(description)
+ dialog.add_button(gtk.STOCK_QUIT, gtk.RESPONSE_CLOSE)
+ dialog.run()
+ sys.exit(0)
start_game()
Modified: trunk/glchess/src/lib/defaults.py.in
==============================================================================
--- trunk/glchess/src/lib/defaults.py.in (original)
+++ trunk/glchess/src/lib/defaults.py.in Fri May 30 00:18:43 2008
@@ -9,12 +9,9 @@
import errno
import gettext
-if (sys.modules.has_key('glchess') and
- hasattr(sys.modules["glchess"],'installed_mode') and
- sys.modules["glchess"].installed_mode):
- # If the installed_mode attribute is not set, then we are
- # importing from something other than the glchess script; we
- # assume anyone importing in this way is doing testing etc.
+root_dir = os.path.dirname(__file__)
+if not os.path.exists(os.path.join(root_dir, 'Makefile.am')):
+ # Running in installed mode
APP_DATA_DIR = os.path.join('@prefix@', 'share')
ICON_DIR = os.path.join(APP_DATA_DIR, 'pixmaps')
TEXTURE_DIR = os.path.join(ICON_DIR, 'glchess')
@@ -30,11 +27,12 @@
GGZ_DIR = os.path.expanduser('~/.ggz')
GGZ_CONFIG_FILE = os.path.join(GGZ_DIR, 'ggz-gtk.rc')
else:
- APP_DATA_DIR = os.path.join('@abs_top_builddir@', 'glchess', 'data')
- ICON_DIR = os.path.join('@abs_top_builddir@', 'glchess', 'textures')
- TEXTURE_DIR = os.path.join('@abs_top_builddir@', 'glchess', 'textures')
- GLADE_DIR = os.path.join('@abs_top_builddir@', 'glchess', 'glade')
- BASE_DIR = os.path.join('@abs_top_builddir@', 'glchess', 'data')
+ # Running in uninstalled mode
+ APP_DATA_DIR = os.path.join(root_dir, '../../data')
+ ICON_DIR = os.path.join(root_dir, '../../textures')
+ TEXTURE_DIR = os.path.join(root_dir, '../../textures')
+ GLADE_DIR = os.path.join(root_dir, '../../glade')
+ BASE_DIR = os.path.join(root_dir, '../../data')
LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
DATA_DIR = os.path.expanduser('~/.gnome2/glchess/')
LOG_DIR = os.path.join(DATA_DIR, 'logs')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]