2 # Copyright(C) 2007, David Aguilar <davvid@gmail.com>
3 # License: GPL v2 or later
8 from os
.path
import join
9 from os
.path
import dirname
11 def setup_environment():
12 """Prepends sys.path with ugit's module path."""
13 version
= platform
.python_version()
15 thisfile
= os
.path
.realpath(__file__
)
16 rootdir
= dirname(dirname(thisfile
))
17 sys
.path
.insert(0, join(rootdir
, 'share'))
19 rootdir
= dirname(os
.getcwd())
20 sys
.path
.insert(0, os
.getcwd())
21 sys
.path
.insert(0, rootdir
)
22 sys
.path
.insert(0, join(rootdir
, 'share'))
26 from PyQt4
import QtCore
27 from PyQt4
import QtGui
29 print "Sorry, you do not seem to have PyQt4 installed."
30 print "Please install it before using ugit."
31 print "e.g.: sudo apt-get install python-qt4"
34 parser
= optparse
.OptionParser(usage
='usage: %prog [options]')
35 parser
.add_option('-p', '--project',
36 help='Path to a git repository',
41 parser
.add_option('-v', '--version',
42 help='Show ugit version',
46 opts
, args
= parser
.parse_args()
48 if opts
.project
and os
.path
.isdir(opts
.project
):
49 os
.chdir(opts
.project
)
51 # This sets up sys.path so that the ugit modules can be found.
54 from ugit
.models
import Model
55 from ugit
.views
import View
56 from ugit
.controllers
import Controller
57 from ugit
import utils
60 from ugit
.version
import VERSION
61 print "ugit version", VERSION
64 app
= QtGui
.QApplication(sys
.argv
)
65 app
.setWindowIcon(QtGui
.QIcon(utils
.get_icon('git.png')))
66 locale
= str(QtCore
.QLocale().system().name())
67 qmfile
= utils
.get_qm_for_locale(locale
)
68 if os
.path
.exists(qmfile
):
69 translator
= QtCore
.QTranslator()
70 translator
.load(qmfile
)
71 app
.installTranslator(translator
)
73 view
= View(app
.activeWindow())
74 ctl
= Controller(model
, view
)
78 if __name__
== "__main__":