1 # Copyright (C) 2006, Thomas Leonard
2 # See http://0install.net/0compile.html
4 # This is normally called by 0launch's GUI.
6 import sys
, os
, __main__
7 from zeroinstall
.injector
.iface_cache
import iface_cache
8 from logging
import info
13 "gui [--no-prompt] [SOURCE-URI]"
15 if args
and args
[0] == '--no-prompt':
24 interface
= env
.interface
29 default_dir
= os
.path
.basename(interface
)
30 if default_dir
.endswith('.xml'):
31 default_dir
= default_dir
[:-4]
32 assert '/' not in default_dir
34 interface
= model
.canonical_iface_uri(args
[0])
36 build_dir
= gui_support
.choose_dir(_('Create build directory'), default_dir
)
37 if not build_dir
: return
39 raise __main__
.UsageError()
43 setup
.setup(interface
, build_dir
, prompt
)
47 box
= gui_support
.CompileBox(interface
)
48 box
.connect('destroy', lambda b
: gtk
.main_quit())
52 except KeyboardInterrupt:
54 except SafeException
, ex
:
55 gui_support
.alert(None, '%s' % ex
)
60 gui_support
.alert(None, '%s: %s' % (ex
.__class
__, ex
))
63 __main__
.commands
.append(do_gui
)