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 from sys import platform
28
29 import gobject
30 import gtk
31 from twisted.internet import reactor
32
33 from flumotion.admin.connections import hasRecentConnections
34 from flumotion.admin.gtk.dialogs import showConnectionErrorDialog
35 from flumotion.common.connection import parsePBConnectionInfo
36 from flumotion.common.errors import ConnectionFailedError, \
37 ConnectionRefusedError
38 from flumotion.common.managerspawner import LocalManagerSpawner
39 from flumotion.common.netutils import tryPort
40 from flumotion.common.pygobject import gsignal
41 from flumotion.configure import configure
42 from flumotion.ui.simplewizard import SimpleWizard, WizardStep, \
43 WizardCancelled
44
45 __version__ = "$Rev: 8734 $"
46 _ = gettext.gettext
47
48
50 name = 'initial'
51 title = _('Connect to Flumotion Manager')
52 text = (_('Flumotion Admin needs to connect to a Flumotion manager.\n') +
53 _('Choose an option from the list and click "Forward" to begin.'))
54 connect_to_existing = None
55 next_pages = ['load_connection',
56 'connect_to_existing',
57 'start_new']
58
67
68
69
70 - def setup(self, state, available_pages):
71
72 for radio in self.load_connection.get_group():
73 isAvailable = radio.get_name() in available_pages
74 radio.set_sensitive(isAvailable)
75
76 hasRecent = hasRecentConnections()
77 self.load_connection.set_sensitive(hasRecent)
78 if hasRecent:
79 self.load_connection.set_active(True)
80 else:
81 self.connect_to_existing.set_active(True)
82
83
84 for radioName in available_pages:
85 radio = getattr(self, radioName)
86 if radio.get_active():
87 break
88 else:
89 raise AssertionError("no button to focus")
90 radio.grab_focus()
91
93 for radio in self.connect_to_existing.get_group():
94 if radio.get_active():
95 return radio.get_name()
96 raise AssertionError
97
98
99
101 if not radio.get_active():
102 return
103 self.button_next.clicked()
104
105
107 name = 'connect_to_existing'
108 title = _('Host Information')
109 text = _('Please enter the address at which the manager is running.')
110 next_pages = ['authenticate']
111 open_connection = None
112
113
114
115 - def setup(self, state, available_pages):
123
124
125
127 self.button_next.set_sensitive(obj.get_property('can-activate'))
128
133
134
169
170
172 name = 'load_connection'
173 title = _('Recent Connections')
174 text = _('Please choose a connection from the box below.')
175 connections = None
176 next_pages = []
177
178
179
180 - def setup(self, state, available_pages):
183
189
190
191
193 self.button_next.emit('clicked')
194
196 self.button_next.set_sensitive(False)
197
198
200 name = 'start_new'
201 title = _('Start a New Manager and Worker')
202 text = _("""This will start a new manager and worker for you.
203
204 The manager and worker will run under your user account.
205 The manager will only accept connections from the local machine.
206 This mode is only useful for testing Flumotion.
207 """)
208 start_worker_check = None
209 next_pages = ['start_new_error', 'start_new_success']
210 gsignal('finished', str)
211
212 _timeout_id = None
213
214
215
216 - def setup(self, state, available_pages):
218
220 self.label_starting.show()
221 self.progressbar_starting.set_fraction(0.0)
222 self.progressbar_starting.show()
223
224 def pulse():
225 self.progressbar_starting.pulse()
226 return True
227 self._timeout_id = gobject.timeout_add(200, pulse)
228
229 self._startManager(state)
230 self.button_prev.set_sensitive(False)
231 return '*signaled*'
232
233
234
243
245
246 state.update({
247 'command': ' '.join(args),
248 'error': msg,
249 'failure': failure,
250 })
251 self._finished('start_new_error')
252
255
270
272
273 self.label_starting.hide()
274 self.progressbar_starting.hide()
275 gobject.source_remove(self._timeout_id)
276 self.emit('finished', result)
277
278
280 name = 'start_new_error'
281 title = _('Failed to Start')
282 text = ""
283 start_worker_check = None
284 next_pages = []
285
286
287
288 - def setup(self, state, available_pages):
289 self.button_next.set_sensitive(False)
290 self.message.set_text(state['error'])
291 f = state['failure']
292 result = ""
293 if f.value.exitCode is not None:
294 result = _('The command exited with an exit code of %d.' %
295 f.value.exitCode)
296 self.more.set_markup(_("""The command that failed was:
297 <i>%s</i>
298 %s""") % (state['command'], result))
299
300
302 name = 'start_new_success'
303 title = _('Started Manager and Worker')
304 start_worker_check = None
305 text = ''
306 next_pages = []
307
308
309
310 - def setup(self, state, available_pages):
311 self.button_prev.set_sensitive(False)
312 self.button_next.set_label(gtk.STOCK_CONNECT)
313 executable = os.path.join(configure.sbindir, 'flumotion')
314 confDir = state['confDir']
315 logDir = state['logDir']
316 runDir = state['runDir']
317 stop = "%s -C %s -L %s -R %s stop" % (
318 executable, confDir, logDir, runDir)
319 self.message.set_markup(_(
320 """The admin client will now connect to the manager.
321
322 Configuration files are stored in
323 <i>%s</i>
324 Log files are stored in
325 <i>%s</i>
326
327 You can shut down the manager and worker later with the following command:
328
329 <i>%s</i>
330 """) % (confDir, logDir, stop))
331 self.button_next.grab_focus()
332
335
336
371
372 def connectionFailed(failure):
373 failure.trap(ConnectionFailedError, ConnectionRefusedError)
374 d = showConnectionErrorDialog(failure, info,
375 parent=self.window)
376 d.addCallback(errorMessageDisplayed)
377 return d
378
379 d = self._adminWindow.openConnection(info, state.get('managerSpawner'))
380 d.addCallbacks(connected, connectionFailed)
381 self.set_sensitive(False)
382 return d
383
385 failure.trap(WizardCancelled)
386 reactor.stop()
387
388
389
390
391
399