#NEWLINE# def main( stdscr ) : #NEWLINE# #INDENT# parser = argparse . ArgumentParser ( ) #NEWLINE# parser . add_argument ( 'user' , type = str ) #NEWLINE# parser . add_argument ( '-v' , '--verbose' , action = 'count' ) #NEWLINE# args = parser . parse_args ( ) #NEWLINE# user = args . user #NEWLINE# server_name = origin_from_ucid ( user ) #NEWLINE# root_logger = logging . getLogger ( ) #NEWLINE# formatter = logging . Formatter ( '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(message)s' ) #NEWLINE# if ( not os . path . exists ( 'logs' ) ) : #NEWLINE# #INDENT# os . makedirs ( 'logs' ) #NEWLINE# #UNINDENT# fh = logging . FileHandler ( ( 'logs/%s' % user ) ) #NEWLINE# fh . setFormatter ( formatter ) #NEWLINE# root_logger . addHandler ( fh ) #NEWLINE# root_logger . setLevel ( logging . DEBUG ) #NEWLINE# log . theLogPublisher . observers = [ ] #NEWLINE# observer = log . PythonLoggingObserver ( ) #NEWLINE# observer . start ( ) #NEWLINE# curses_stdio = cursesio . CursesStdIO ( stdscr ) #NEWLINE# input_output = InputOutput ( curses_stdio , user ) #NEWLINE# curses_stdio . set_callback ( input_output ) #NEWLINE# app_hs = SynapseHomeServer ( server_name , db_name = ( 'dbs/%s' % user ) ) #NEWLINE# replication = app_hs . get_replication_layer ( ) #NEWLINE# hs = HomeServer ( server_name , replication , curses_stdio ) #NEWLINE# input_output . set_home_server ( hs ) #NEWLINE# io_logger = IOLoggerHandler ( input_output ) #NEWLINE# io_logger . setFormatter ( formatter ) #NEWLINE# root_logger . addHandler ( io_logger ) #NEWLINE# try : #NEWLINE# #INDENT# port = int ( server_name . split ( ':' ) [ 1 ] ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# port = 12345 #NEWLINE# #UNINDENT# app_hs . get_http_server ( ) . start_listening ( port ) #NEWLINE# reactor . addReader ( curses_stdio ) #NEWLINE# reactor . run ( )