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
48 from ugit.models import Model
49 from ugit import utils
50 from ugit.views import View
51 from ugit.controllers import Controller
54 for repo in [ os.path.realpath(r) for r in args[1:] ]:
55 utils.fork("git", "ugit", repo)
57 # load the model right away so that we can bail out if
58 # when no git repo exists
64 from PyQt4 import QtCore
65 from PyQt4 import QtGui
67 print "Sorry, you do not seem to have PyQt4 installed."
68 print "Please install it before using ugit."
69 print "e.g.: sudo apt-get install python-qt4"
72 app = QtGui.QApplication(sys.argv)
73 app.setWindowIcon(QtGui.QIcon( utils.get_icon('git
.png
')) )
74 locale = str(QtCore.QLocale().system().name())
75 qmfile = utils.get_qm_for_locale( locale )
76 if os.path.exists(qmfile):
77 translator = QtCore.QTranslator()
78 translator.load(qmfile)
79 app.installTranslator(translator)
81 view = View(app.activeWindow())
82 ctl = Controller(model, view)
86 if __name__ == "__main__":