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