2 # Copyright(C) 2007, David Aguilar <davvid@gmail.com>
3 # License: GPL v2 or later
7 from os
.path
import join
8 from os
.path
import dirname
9 from os
.path
import realpath
11 def setup_environment():
12 """Prepends sys.path with ugit's module path."""
13 # ex: sys.path = [ ..., /usr/share ]
14 # from ugit import git
15 # implies: git = /usr/share/ugit/git.py
16 ugit
= realpath(sys
.argv
[0])
19 share
= join(prefix
,'share')
20 sys
.path
.insert(0, share
)
24 parser
= optparse
.OptionParser(
25 usage
='%prog /repo/path-1 ... /repo/path-N*\n\n'
26 +'*the current directory is used when no '
27 +'paths are specified.''')
28 parser.add_option('-v
', '--version
',
29 help='Show ugit version
',
33 opts, args = parser.parse_args()
35 # allow "git ugit /path/to/repo"
37 os.chdir(os.path.realpath(args[0]))
39 # This sets up sys.path so that the ugit modules can be found.
43 from ugit.version import VERSION
44 print "ugit version", VERSION
47 # allow "git ugit /repo/path-1 .. /repo/path-N
49 for repo in [ os.path.realpath(r) for r in args[1:] ]:
50 from ugit.utils import fork
51 fork( sys.argv[0], repo )
54 from ugit.models import Model
55 from ugit import utils
56 from ugit.views import View
57 from ugit.controllers import Controller
59 # load the model right away so that we can bail out if
60 # when no git repo exists
66 from PyQt4 import QtCore
67 from PyQt4 import QtGui
69 print "Sorry, you do not seem to have PyQt4 installed."
70 print "Please install it before using ugit."
71 print "e.g.: sudo apt-get install python-qt4"
74 app = QtGui.QApplication(sys.argv)
75 app.setWindowIcon(QtGui.QIcon( utils.get_icon('git
.png
')) )
76 locale = str(QtCore.QLocale().system().name())
77 qmfile = utils.get_qm_for_locale( locale )
78 if os.path.exists(qmfile):
79 translator = QtCore.QTranslator()
80 translator.load(qmfile)
81 app.installTranslator(translator)
83 view = View(app.activeWindow())
84 ctl = Controller(model, view)
88 if __name__ == "__main__":