Package flumotion :: Package admin :: Package text :: Module main
[hide private]

Source Code for Module flumotion.admin.text.main

  1  # -*- Mode: Python -*- 
  2  # vi:si:et:sw=4:sts=4:ts=4 
  3  # 
  4  # Flumotion - a streaming media server 
  5  # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 
  6  # All rights reserved. 
  7   
  8  # This file may be distributed and/or modified under the terms of 
  9  # the GNU General Public License version 2 as published by 
 10  # the Free Software Foundation. 
 11  # This file is distributed without any warranty; without even the implied 
 12  # warranty of merchantability or fitness for a particular purpose. 
 13  # See "LICENSE.GPL" in the source distribution for more information. 
 14   
 15  # Licensees having purchased or holding a valid Flumotion Advanced 
 16  # Streaming Server license may use this file in accordance with the 
 17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
 18  # See "LICENSE.Flumotion" in the source distribution for more information. 
 19   
 20  # Headers in this file shall remain intact. 
 21   
 22  """flumotion-admin-text entry point, command line parsing and invokation""" 
 23   
 24  import curses 
 25   
 26  from twisted.internet import reactor 
 27   
 28  from flumotion.admin.text import connection 
 29  from flumotion.admin.text.greeter import AdminTextGreeter 
 30  from flumotion.common import messages # make Message proxyable 
 31  from flumotion.common.options import OptionParser 
 32  from flumotion.common.connection import PBConnectionInfo 
 33  from flumotion.twisted import pb as fpb 
 34   
 35  __version__ = "$Rev$" 
 36   
 37   
38 -def cleanup_curses(stdscr):
39 curses.nocbreak() 40 stdscr.keypad(0) 41 curses.echo() 42 curses.endwin()
43 44
45 -def _runInterface(options):
46 # initialise curses 47 48 stdscr = curses.initscr() 49 curses.noecho() 50 curses.cbreak() 51 stdscr.nodelay(1) 52 stdscr.keypad(1) 53 54 reactor.addSystemEventTrigger('after', 55 'shutdown', cleanup_curses, stdscr) 56 57 58 # first lets sort out logging in 59 username = 'user' 60 password = 'test' 61 hostname = 'localhost' 62 insecure = False 63 port = 7531 64 if options.username and options.password and options.hostname: 65 username = options.username 66 password = options.password 67 hostname = options.hostname 68 if options.port: 69 try: 70 port = int(options.port) 71 except ValueError: 72 pass 73 if options.insecure: 74 insecure = True 75 authenticator = fpb.Authenticator(username=username, password=password) 76 info = PBConnectionInfo(hostname, port, not insecure, authenticator) 77 connection.connect_to_manager(stdscr, info) 78 79 else: 80 # do greeter 81 # get recent connections 82 greeter = AdminTextGreeter(stdscr) 83 reactor.addReader(greeter) 84 greeter.show()
85 86
87 -def main(args):
88 parser = OptionParser(domain="flumotion-admin-text") 89 parser.add_option('-u', '--username', 90 action="store", type="string", dest="username", 91 help="set username to connect to manager") 92 parser.add_option('-P', '--password', 93 action="store", type="string", dest="password", 94 help="set password to connect to manager") 95 parser.add_option('-H', '--hostname', 96 action="store", type="string", dest="hostname", 97 help="set hostname of manager to connect to") 98 parser.add_option('-p', '--port', 99 action="store", type="string", dest="port", 100 help="set port of manager to connect to") 101 parser.add_option('', '--insecure', 102 action="store_true", dest="insecure", 103 help="make insecure connection") 104 105 options, args = parser.parse_args(args) 106 107 _runInterface(options) 108 109 reactor.run()
110