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

Proposed by Jelmer Vernooij
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
tribunal/app.py (+28/-28)
To merge this branch: bzr merge lp:~jelmer/tribunal/fix-no-args
Reviewer Review Type Date Requested Status
Martin Pool Approve
The Tribunal code 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.
Revision history for this message
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
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

Yep, exactly.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tribunal/app.py'
--- tribunal/app.py 2010-08-22 00:55:27 +0000
+++ tribunal/app.py 2010-09-27 09:06:45 +0000
@@ -76,44 +76,44 @@
76 opts, args = parser.parse_args(argv)76 opts, args = parser.parse_args(argv)
7777
78 if opts.testr:78 if opts.testr:
79 source = TestRepositorySource(opts.testr) 79 source = TestRepositorySource(opts.testr)
80 elif args == ['-']:80 elif args == ['-']:
81 source = FileTestSource(sys.stdin)81 source = FileTestSource(sys.stdin)
82 elif len(args) == 1:82 elif len(args) == 1:
83 if os.path.isdir(args[0]):83 if os.path.isfile(args[0]):
84 source = TestRepositorySource(".")
85 else:
86 source = FileTestSource(file(args[0], 'rb'))84 source = FileTestSource(file(args[0], 'rb'))
87 elif os.path.exists(os.path.join(args[0], ".testr.conf")):85 elif os.path.isdir(os.path.join(args[0], ".testrepository")):
88 dialog = gtk.Dialog(title="No testrepository present",
89 parent=None,
90 buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
91 gtk.STOCK_NO, gtk.RESPONSE_NO))
92 label = gtk.Label("No test repository is present. Create one?")
93 dialog.vbox.pack_start(label, True, True, 0)
94 label.show()
95 resp = dialog.run()
96 dialog.destroy()
97 if resp == gtk.RESPONSE_YES:
98 import testrepository.repository.file
99 factory = testrepository.repository.file.RepositoryFactory()
100 factory.initialise(".")
101 source = TestRepositorySource(".")86 source = TestRepositorySource(".")
87 elif os.path.exists(os.path.join(args[0], ".testr.conf")):
88 dialog = gtk.Dialog(title="No testrepository present",
89 parent=None,
90 buttons=(gtk.STOCK_YES, gtk.RESPONSE_YES,
91 gtk.STOCK_NO, gtk.RESPONSE_NO))
92 label = gtk.Label("No test repository is present. Create one?")
93 dialog.vbox.pack_start(label, True, True, 0)
94 label.show()
95 resp = dialog.run()
96 dialog.destroy()
97 if resp == gtk.RESPONSE_YES:
98 import testrepository.repository.file
99 factory = testrepository.repository.file.RepositoryFactory()
100 factory.initialise(".")
101 source = TestRepositorySource(".")
102 else:102 else:
103 print "Unable to open %s" % args[0]
103 sys.exit(1)104 sys.exit(1)
104 else:105 else:
105 print "usage: tribunal-subunit SUBUNIT_FILE"106 source = None
106 print " tribunal-subunit --testr DIR"
107 sys.exit(1)
108107
109 self._construct_and_show_window()108 self._construct_and_show_window()
110 self._window.set_source(source)109 if source is not None:
111 try:110 self._window.set_source(source)
112 stream = source.get_subunit_stream()111 try:
113 except NoStreamPresent:112 stream = source.get_subunit_stream()
114 pass113 except NoStreamPresent:
115 else:114 pass
116 self._window.load_from_subunit_stream(stream)115 else:
116 self._window.load_from_subunit_stream(stream)
117 self._event_loop.start()117 self._event_loop.start()
118118
119 def _set_default_icons(self):119 def _set_default_icons(self):

Subscribers

People subscribed via source and target branches

to all changes: