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