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 ConnectionRefusedError, OptionError
33 from flumotion.common.options import OptionParser
34
35 __version__ = "$Rev: 7082 $"
36 _ = gettext.gettext
37 _retval = 0
38
55
56 def errback(failure):
57 global _retval
58 print >> sys.stderr, "ERROR: %s" % (failure.value,)
59 _retval = 1
60 reactor.stop()
61 d.addErrback(errbackConnectionRefused)
62 d.addErrback(errback)
63 return d
64
82
84 global _retval
85
86 parser = OptionParser(domain="flumotion-admin")
87 parser.add_option('-m', '--manager',
88 action="store", type="string", dest="manager",
89 help="the manager to connect to, e.g. localhost:7531")
90 parser.add_option('', '--no-ssl',
91 action="store_false", dest="ssl", default=True,
92 help="disable encryption when connecting to the manager")
93
94 options, args = parser.parse_args(args)
95
96 i18n.installGettext()
97
98 if len(args) > 1:
99 log.error('flumotion-admin',
100 'too many arguments: %r' % (args[1:],))
101 return 1
102
103 from flumotion.ui.icons import register_icons
104 register_icons()
105
106 sys.excepthook = _exceptionHandler
107
108 from flumotion.admin.gtk.adminwindow import AdminWindow
109 win = AdminWindow()
110
111 if options.verbose or (options.debug and options.debug > 3):
112 win.setDebugEnabled(True)
113
114 if options.manager:
115 d = _connectToManager(win, options.manager, options.ssl)
116 else:
117 from flumotion.admin.gtk.greeter import Greeter
118 greeter = Greeter(win)
119 d = greeter.runAsync()
120
121
122 d.addErrback(twistedlog.err)
123
124 reactor.run()
125 return _retval
126