1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """flumotion-admin entry point, command line parsing and invokation"""
23
24 import gettext
25 import sys
26
27 from twisted.internet import reactor
28 from twisted.python import log as twistedlog
29
30 from flumotion.admin.connections import parsePBConnectionInfoRecent
31 from flumotion.common import log, i18n
32 from flumotion.common.errors import OptionError, ConnectionRefusedError,\
33 ConnectionFailedError
34 from flumotion.common.options import OptionParser
35
36 __version__ = "$Rev$"
37 _ = gettext.gettext
38 _retval = 0
39
40
46
47
59
60 def errorDialogShown(unused):
61 return showGreeter(win)
62
63 def connectionFailed(failure):
64 failure.trap(ConnectionRefusedError, ConnectionFailedError)
65 from flumotion.admin.gtk.dialogs import showConnectionErrorDialog
66 d = showConnectionErrorDialog(failure, info)
67 d.addCallback(errorDialogShown)
68 return d
69
70 d = win.openConnection(info)
71 d.addErrback(connectionFailed)
72 d.addErrback(errback)
73 return d
74
75
77 global _retval
78
79 parser = OptionParser(domain="flumotion-admin")
80 parser.add_option('-m', '--manager',
81 action="store", type="string", dest="manager",
82 help="the manager to connect to, e.g. localhost:7531")
83 parser.add_option('', '--no-ssl',
84 action="store_false", dest="ssl", default=True,
85 help="disable encryption when connecting to the manager")
86
87 options, args = parser.parse_args(args)
88
89 i18n.installGettext()
90
91 if len(args) > 1:
92 log.error('flumotion-admin',
93 'too many arguments: %r' % (args[1:], ))
94 return 1
95
96 from flumotion.ui.icons import register_icons
97 register_icons()
98
99 from flumotion.admin.gtk.dialogs import exceptionHandler
100 sys.excepthook = exceptionHandler
101
102 from flumotion.admin.gtk.adminwindow import AdminWindow
103 win = AdminWindow()
104
105 if options.verbose or (options.debug and options.debug > 3):
106 win.setDebugEnabled(True)
107
108 if options.manager:
109 d = _connectToManager(win, options.manager, options.ssl)
110 else:
111 d = showGreeter(win)
112
113
114 d.addErrback(twistedlog.err)
115
116
117
118 if not hasattr(reactor, '_simtag'):
119 reactor._simtag = None
120
121 reactor.run()
122 return _retval
123