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: 8057 $"
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 return '*signaled*'
231
232
233
242
244
245 state.update({
246 'command': ' '.join(args),
247 'error': msg,
248 'failure': failure,
249 })
250 self._finished('start_new_error')
251
254
268
270
271 self.label_starting.hide()
272 self.progressbar_starting.hide()
273 gobject.source_remove(self._timeout_id)
274 self.emit('finished', result)
275
276
278 name = 'start_new_error'
279 title = _('Failed to Start')
280 text = ""
281 start_worker_check = None
282 next_pages = []
283
284
285
286 - def setup(self, state, available_pages):
287 self.button_next.set_sensitive(False)
288 self.message.set_text(state['error'])
289 f = state['failure']
290 result = ""
291 if f.value.exitCode is not None:
292 result = _('The command exited with an exit code of %d.' %
293 f.value.exitCode)
294 self.more.set_markup(_("""The command that failed was:
295 <i>%s</i>
296 %s""") % (state['command'], result))
297
298
300 name = 'start_new_success'
301 title = _('Started Manager and Worker')
302 start_worker_check = None
303 text = ''
304 next_pages = []
305
306
307
308 - def setup(self, state, available_pages):
309 self.button_prev.set_sensitive(False)
310 self.button_next.set_label(gtk.STOCK_CONNECT)
311 executable = os.path.join(configure.sbindir, 'flumotion')
312 confDir = state['confDir']
313 logDir = state['logDir']
314 runDir = state['runDir']
315 stop = "%s -C %s -L %s -R %s stop" % (
316 executable, confDir, logDir, runDir)
317 self.message.set_markup(_(
318 """The admin client will now connect to the manager.
319
320 Configuration files are stored in
321 <i>%s</i>
322 Log files are stored in
323 <i>%s</i>
324
325 You can shut down the manager and worker later with the following command:
326
327 <i>%s</i>
328 """) % (confDir, logDir, stop))
329 self.button_next.grab_focus()
330
333
334
369
370 def connectionFailed(failure):
371 failure.trap(ConnectionFailedError, ConnectionRefusedError)
372 d = showConnectionErrorDialog(failure, info,
373 parent=self.window)
374 d.addCallback(errorMessageDisplayed)
375 return d
376
377 d = self._adminWindow.openConnection(info)
378 d.addCallbacks(connected, connectionFailed)
379 self.set_sensitive(False)
380 return d
381
383 failure.trap(WizardCancelled)
384 reactor.stop()
385
386
387
388
389
397