1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """greeter interface, displayed when the user first starts flumotion.
23 """
24
25 import gettext
26 import os
27
28 import gobject
29 import gtk
30 from twisted.internet import reactor
31
32 from flumotion.admin.connections import hasRecentConnections
33 from flumotion.admin.gtk.dialogs import showConnectionErrorDialog
34 from flumotion.common.connection import parsePBConnectionInfo
35 from flumotion.common.errors import ConnectionFailedError
36 from flumotion.common.managerspawner import LocalManagerSpawner
37 from flumotion.common.netutils import tryPort
38 from flumotion.common.pygobject import gsignal
39 from flumotion.configure import configure
40 from flumotion.ui.simplewizard import SimpleWizard, WizardStep, \
41 WizardCancelled
42
43 __version__ = "$Rev: 7032 $"
44 _ = gettext.gettext
45
46
48 name = 'initial'
49 title = _('Connect to Flumotion manager')
50 text = (_('Flumotion Admin needs to connect to a Flumotion manager.\n') +
51 _('Choose an option from the list and click "Forward" to begin.'))
52 connect_to_existing = None
53 next_pages = ['load_connection',
54 'connect_to_existing',
55 'start_new']
56
62
63
64
65 - def setup(self, state, available_pages):
66
67 for radio in self.load_connection.get_group():
68 isAvailable = radio.get_name() in available_pages
69 radio.set_sensitive(isAvailable)
70
71 hasRecent = hasRecentConnections()
72 self.load_connection.set_sensitive(hasRecent)
73 if hasRecent:
74 self.load_connection.set_active(True)
75 else:
76 self.connect_to_existing.set_active(True)
77
78
79 for radioName in available_pages:
80 radio = getattr(self, radioName)
81 if radio.get_active():
82 break
83 else:
84 raise AssertionError("no button to focus")
85 radio.grab_focus()
86
92
93
94
96 if not radio.get_active():
97 return
98 self.button_next.clicked()
99
100
102 name = 'connect_to_existing'
103 title = _('Host information')
104 text = _('Please enter the address where the manager is running.')
105 next_pages = ['authenticate']
106 open_connection = None
107
108
109
110 - def setup(self, state, available_pages):
117
118
119
121 self.button_next.set_sensitive(obj.get_property('can-activate'))
122
127
128
163
164
166 name = 'load_connection'
167 title = _('Recent connections')
168 text = _('Please choose a connection from the box below.')
169 connections = None
170 next_pages = []
171
172
173
174 - def setup(self, state, available_pages):
177
183
184
185
187 self.button_next.emit('clicked')
188
189
191 name = 'start_new'
192 title = _('Start a new manager and worker')
193 text = _("""This will start a new manager and worker for you.
194
195 The manager and worker will run under your user account.
196 The manager will only accept connections from the local machine.
197 This mode is only useful for testing Flumotion.
198 """)
199 start_worker_check = None
200 next_pages = ['start_new_error', 'start_new_success']
201 gsignal('finished', str)
202
203 _timeout_id = None
204
205
206
207 - def setup(self, state, available_pages):
209
211 self.label_starting.show()
212 self.progressbar_starting.set_fraction(0.0)
213 self.progressbar_starting.show()
214
215 def pulse():
216 self.progressbar_starting.pulse()
217 return True
218 self._timeout_id = gobject.timeout_add(200, pulse)
219
220 self._startManager(state)
221 return '*signaled*'
222
223
224
233
235
236 state.update({
237 'command': ' '.join(args),
238 'error': msg,
239 'failure': failure,
240 })
241 self._finished('start_new_error')
242
245
259
261
262 self.label_starting.hide()
263 self.progressbar_starting.hide()
264 gobject.source_remove(self._timeout_id)
265 self.emit('finished', result)
266
267
269 name = 'start_new_error'
270 title = _('Failed to start')
271 text = ""
272 start_worker_check = None
273 next_pages = []
274
275
276
277 - def setup(self, state, available_pages):
278 self.button_next.set_sensitive(False)
279 self.message.set_text(state['error'])
280 f = state['failure']
281 result = ""
282 if f.value.exitCode is not None:
283 result = _('The command exited with an exit code of %d.' %
284 f.value.exitCode)
285 self.more.set_markup(_("""The command that failed was:
286 <i>%s</i>
287 %s""") % (state['command'], result))
288
289
291 name = 'start_new_success'
292 title = _('Started manager and worker')
293 start_worker_check = None
294 text = ''
295 next_pages = []
296
297
298
299 - def setup(self, state, available_pages):
300 self.button_prev.set_sensitive(False)
301 self.button_next.set_label(gtk.STOCK_CONNECT)
302 executable = os.path.join(configure.sbindir, 'flumotion')
303 confDir = state['confDir']
304 logDir = state['logDir']
305 runDir = state['runDir']
306 stop = "%s -C %s -L %s -R %s stop" % (
307 executable, confDir, logDir, runDir)
308 self.message.set_markup(_(
309 """The admin client will now connect to the manager.
310
311 Configuration files are stored in
312 <i>%s</i>
313 Log files are stored in
314 <i>%s</i>
315
316 You can shut down the manager and worker later with the following command:
317
318 <i>%s</i>
319 """) % (confDir, logDir, stop))
320 self.button_next.grab_focus()
321
324
325
360
361 def connectionFailed(failure):
362 failure.trap(ConnectionFailedError)
363 self.hide()
364 d = showConnectionErrorDialog(failure, info,
365 parent=self.window)
366 d.addCallback(errorMessageDisplayed)
367 return d
368
369 d = self._adminWindow.openConnection(info)
370 d.addCallbacks(connected, connectionFailed)
371 self.set_sensitive(False)
372 return d
373
375 failure.trap(WizardCancelled)
376 reactor.stop()
377
378
379
387