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