2 # Copyright(C) 2007, David Aguilar <davvid@gmail.com>
3 # License: GPL v2 or later
9 def setup_environment():
10 """Prepends sys.path with ugit's module path."""
11 version
= platform
.python_version()
13 thisfile
= os
.path
.realpath(__file__
)
14 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(thisfile
)))
15 sys
.path
.insert(0, os
.path
.join(
16 os
.path
.dirname(os
.path
.dirname(thisfile
)),
17 'lib', 'python' + version
[:3],
20 ugitmodules
= os
.path
.dirname(thisfile
)
21 if ugitmodules
not in sys
.path
:
22 sys
.path
.insert(0, os
.path
.dirname(thisfile
))
24 sys
.path
.insert(0, os
.getcwd())
28 from PyQt4
import QtCore
29 from PyQt4
import QtGui
31 print "Sorry, you do not seem to have PyQt4 installed."
32 print "Please install it before using ugit."
33 print "e.g.: sudo apt-get install python-qt4"
36 parser
= optparse
.OptionParser(usage
='usage: %prog [options]')
37 parser
.add_option('-p', '--project',
38 help='Path to a git repository',
43 parser
.add_option('-v', '--version',
44 help='Show ugit version',
48 opts
, args
= parser
.parse_args()
50 if opts
.project
and os
.path
.isdir(opts
.project
):
51 os
.chdir(opts
.project
)
53 # This sets up sys.path so that the ugit modules can be found.
56 from ugit
.models
import Model
57 from ugit
.views
import View
58 from ugit
.controllers
import Controller
59 from ugit
import utils
62 from ugit
.version
import VERSION
63 print "ugit version", VERSION
66 app
= QtGui
.QApplication(sys
.argv
)
67 app
.setWindowIcon(QtGui
.QIcon(utils
.get_icon('git.png')))
68 locale
= str(QtCore
.QLocale().system().name())
69 qmfile
= utils
.get_qm_for_locale(locale
)
70 if os
.path
.exists(qmfile
):
71 translator
= QtCore
.QTranslator()
72 translator
.load(qmfile
)
73 app
.installTranslator(translator
)
75 view
= View(app
.activeWindow())
76 ctl
= Controller(model
, view
)
80 if __name__
== "__main__":