1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2025-12-17 19:40:21 +01:00

* Added imports checks.

* Added catch for keyboard interrupt exception for gracely quit.
This commit is contained in:
2007-05-05 20:13:42 +00:00
parent 98ef8ee6c7
commit 793716c66d

View File

@@ -1,4 +1,5 @@
# This Python file uses the following encoding: utf-8
def setup_path():
"""Sets up the python include paths to include src"""
import os.path; import sys
@@ -12,6 +13,55 @@ def setup_path():
if __name__ == "__main__":
setup_path()
import sys
import os
try:
from models.m_config import ConfigModel
except:
print "Some fundamental files are missing. try runnig pyGTKtalog in his root directory"
sys.exit(1)
conf = ConfigModel()
try:
import pygtk
#tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
except:
#Some distributions come with GTK2, but not pyGTK
pass
try:
import gtk
import gtk.glade
except:
print "You need to install pyGTK or GTKv2 ",
print "or set your PYTHONPATH correctly."
print "try: export PYTHONPATH=",
print "/usr/local/lib/python2.2/site-packages/"
sys.exit(1)
try:
from pysqlite2 import dbapi2 as sqlite
import mx.DateTime
except:
print "pyGTKtalog uses SQLite DB.\nYou'll need to get it and the python bindings as well.\nhttp://www.sqlite.org\nhttp://initd.org/tracker/pysqlite"
sys.exit(1)
if conf.confd['exportxls']:
try:
import pyExcelerator
except:
print "You'll need pyExcelerator, if you want to export DB to XLS format.\nhttp://sourceforge.net/projects/pyexcelerator"
sys.exit(1)
if conf.confd['pil']:
try:
import Image, ImageEnhance
except:
print "You'll need Python Imaging Library (PIL), if you want to make thumbnails"
sys.exit(1)
from models.m_main import MainModel
from controllers.c_main import MainController
from views.v_main import MainView
@@ -20,5 +70,16 @@ if __name__ == "__main__":
v = MainView(c)
import gtk
gtk.main()
try:
gtk.main()
except KeyboardInterrupt:
import os
#c.storeSettings()
#c.cur.close()
#c.con.close()
try:
os.unlink(c.db_tmp_filename)
except:
pass
gtk.main_quit
pass