Merge lp:~jelmer/tribunal/fix-no-args into lp:tribunal

Proposed by Jelmer Vernooij on 2010-09-27
Status: Merged
Merged at revision: 168
Proposed branch: lp:~jelmer/tribunal/fix-no-args
Merge into: lp:tribunal
Diff against target: 76 lines (+28/-28) 1 file modified
To merge this branch: bzr merge lp:~jelmer/tribunal/fix-no-args
Reviewer Review Type Date Requested Status
Martin Pool Approve on 2010-09-29
The Tribunal code 2010-09-27 Pending
Review via email: mp+36688@code.launchpad.net

Commit Message

Support running 'tribunal-subunit' with no arguments.

Description of the Change

Support running 'tribunal-subunit' with no arguments - this will just bring up the main window.

This is useful when launching tribunal-subunit from the Applications menu.

To post a comment you must log in.
Martin Pool (mbp) wrote :

I guess for the moment this means you get a useless window, but it will become useful when we add a file/open option?

review: Approve
Jelmer Vernooij (jelmer) wrote :

Yep, exactly.

Preview Diff

1=== modified file 'tribunal/app.py'
2--- tribunal/app.py 2010-08-22 00:55:27 +0000
3+++ tribunal/app.py 2010-09-27 09:06:45 +0000
4@@ -76,44 +76,44 @@
5 opts, args = parser.parse_args(argv)
6
7 if opts.testr:
8- source = TestRepositorySource(opts.testr)
9+ source = TestRepositorySource(opts.testr)
10 elif args == ['-']:
11 source = FileTestSource(sys.stdin)
12 elif len(args) == 1:
13- if os.path.isdir(args[0]):
14- source = TestRepositorySource(".")
15- else:
16+ if os.path.isfile(args[0]):
17 source = FileTestSource(file(args[0], 'rb'))
18- elif os.path.exists(os.path.join(args[0], ".testr.conf")):
19- dialog = gtk.Dialog(title="No testrepository present",
20- parent=None,
21- buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
22- gtk.STOCK_NO, gtk.RESPONSE_NO))
23- label = gtk.Label("No test repository is present. Create one?")
24- dialog.vbox.pack_start(label, True, True, 0)
25- label.show()
26- resp = dialog.run()
27- dialog.destroy()
28- if resp == gtk.RESPONSE_YES:
29- import testrepository.repository.file
30- factory = testrepository.repository.file.RepositoryFactory()
31- factory.initialise(".")
32+ elif os.path.isdir(os.path.join(args[0], ".testrepository")):
33 source = TestRepositorySource(".")
34+ elif os.path.exists(os.path.join(args[0], ".testr.conf")):
35+ dialog = gtk.Dialog(title="No testrepository present",
36+ parent=None,
37+ buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
38+ gtk.STOCK_NO, gtk.RESPONSE_NO))
39+ label = gtk.Label("No test repository is present. Create one?")
40+ dialog.vbox.pack_start(label, True, True, 0)
41+ label.show()
42+ resp = dialog.run()
43+ dialog.destroy()
44+ if resp == gtk.RESPONSE_YES:
45+ import testrepository.repository.file
46+ factory = testrepository.repository.file.RepositoryFactory()
47+ factory.initialise(".")
48+ source = TestRepositorySource(".")
49 else:
50+ print "Unable to open %s" % args[0]
51 sys.exit(1)
52 else:
53- print "usage: tribunal-subunit SUBUNIT_FILE"
54- print " tribunal-subunit --testr DIR"
55- sys.exit(1)
56+ source = None
57
58 self._construct_and_show_window()
59- self._window.set_source(source)
60- try:
61- stream = source.get_subunit_stream()
62- except NoStreamPresent:
63- pass
64- else:
65- self._window.load_from_subunit_stream(stream)
66+ if source is not None:
67+ self._window.set_source(source)
68+ try:
69+ stream = source.get_subunit_stream()
70+ except NoStreamPresent:
71+ pass
72+ else:
73+ self._window.load_from_subunit_stream(stream)
74 self._event_loop.start()
75
76 def _set_default_icons(self):

Subscribers

People subscribed via source and target branches

to all changes: