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   
 33  __version__ = "$Rev: 6961 $" 
 34   
 35   
36 -def cleanup_curses(stdscr):
37 curses.nocbreak() 38 stdscr.keypad(0) 39 curses.echo() 40 curses.endwin()
41
42 -def _runInterface(options):
43 # initialise curses 44 45 stdscr = curses.initscr() 46 curses.noecho() 47 curses.cbreak() 48 stdscr.nodelay(1) 49 stdscr.keypad(1) 50 51 reactor.addSystemEventTrigger('after','shutdown', cleanup_curses, stdscr) 52 53 54 # first lets sort out logging in 55 username = 'user' 56 password = 'test' 57 hostname = 'localhost' 58 insecure = False 59 port = 7531 60 if options.username and options.password and options.hostname: 61 username = options.username 62 password = options.password 63 hostname = options.hostname 64 if options.port: 65 try: 66 port = int(options.port) 67 except ValueError: 68 pass 69 if options.insecure: 70 insecure = True 71 connection.connect_to_manager(stdscr, hostname, port, insecure, username, password) 72 73 else: 74 # do greeter 75 # get recent connections 76 greeter = AdminTextGreeter(stdscr) 77 reactor.addReader(greeter) 78 greeter.show()
79
80 -def main(args):
81 parser = OptionParser(domain="flumotion-admin-text") 82 parser.add_option('-u', '--username', 83 action="store", type="string", dest="username", 84 help="set username to connect to manager") 85 parser.add_option('-P', '--password', 86 action="store", type="string", dest="password", 87 help="set password to connect to manager") 88 parser.add_option('-H', '--hostname', 89 action="store", type="string", dest="hostname", 90 help="set hostname of manager to connect to") 91 parser.add_option('-p', '--port', 92 action="store", type="string", dest="port", 93 help="set port of manager to connect to") 94 parser.add_option('', '--insecure', 95 action="store_true", dest="insecure", 96 help="make insecure connection") 97 98 options, args = parser.parse_args(args) 99 100 _runInterface(options) 101 102 reactor.run()
103