Ejemplo n.º 1
0
def main(stdscr):
    parser = argparse.ArgumentParser()
    parser.add_argument("user", type=str)
    parser.add_argument("-v", "--verbose", action="count")
    args = parser.parse_args()

    user = args.user
    server_name = origin_from_ucid(user)

    ## Set up logging ##

    root_logger = logging.getLogger()

    formatter = logging.Formatter(
        "%(asctime)s - %(name)s - %(lineno)d - " "%(levelname)s - %(message)s"
    )
    if not os.path.exists("logs"):
        os.makedirs("logs")
    fh = logging.FileHandler("logs/%s" % user)
    fh.setFormatter(formatter)

    root_logger.addHandler(fh)
    root_logger.setLevel(logging.DEBUG)

    # Hack: The only way to get it to stop logging to sys.stderr :(
    log.theLogPublisher.observers = []
    observer = log.PythonLoggingObserver()
    observer.start()

    ## Set up synapse server

    curses_stdio = cursesio.CursesStdIO(stdscr)
    input_output = InputOutput(curses_stdio, user)

    curses_stdio.set_callback(input_output)

    app_hs = SynapseHomeServer(server_name, db_name="dbs/%s" % user)
    replication = app_hs.get_replication_layer()

    hs = HomeServer(server_name, replication, curses_stdio)

    input_output.set_home_server(hs)

    ## Add input_output logger
    io_logger = IOLoggerHandler(input_output)
    io_logger.setFormatter(formatter)
    root_logger.addHandler(io_logger)

    ## Start! ##

    try:
        port = int(server_name.split(":")[1])
    except:
        port = 12345

    app_hs.get_http_server().start_listening(port)

    reactor.addReader(curses_stdio)

    reactor.run()
Ejemplo n.º 2
0
def main(stdscr):
    parser = argparse.ArgumentParser()
    parser.add_argument('user', type=str)
    parser.add_argument('-v', '--verbose', action='count')
    args = parser.parse_args()

    user = args.user
    server_name = origin_from_ucid(user)

    ## Set up logging ##

    root_logger = logging.getLogger()

    formatter = logging.Formatter('%(asctime)s - %(name)s - %(lineno)d - '
            '%(levelname)s - %(message)s')
    if not os.path.exists("logs"):
        os.makedirs("logs")
    fh = logging.FileHandler("logs/%s" % user)
    fh.setFormatter(formatter)

    root_logger.addHandler(fh)
    root_logger.setLevel(logging.DEBUG)

    # Hack: The only way to get it to stop logging to sys.stderr :(
    log.theLogPublisher.observers = []
    observer = log.PythonLoggingObserver()
    observer.start()

    ## Set up synapse server

    curses_stdio = cursesio.CursesStdIO(stdscr)
    input_output = InputOutput(curses_stdio, user)

    curses_stdio.set_callback(input_output)

    app_hs = SynapseHomeServer(server_name, db_name="dbs/%s" % user)
    replication = app_hs.get_replication_layer()

    hs = HomeServer(server_name, replication, curses_stdio)

    input_output.set_home_server(hs)

    ## Add input_output logger
    io_logger = IOLoggerHandler(input_output)
    io_logger.setFormatter(formatter)
    root_logger.addHandler(io_logger)

    ## Start! ##

    try:
        port = int(server_name.split(":")[1])
    except:
        port = 12345

    app_hs.get_http_server().start_listening(port)

    reactor.addReader(curses_stdio)

    reactor.run()
Ejemplo n.º 3
0
    def add_participant(self, participant):
        """Someone has joined the room"""
        self.participants.add(participant)
        self.invited.discard(participant)

        server = origin_from_ucid(participant)
        self.servers.add(server)

        if not self.oldest_server:
            self.oldest_server = server
Ejemplo n.º 4
0
    def add_participant(self, participant):
        """ Someone has joined the room
        """
        self.participants.add(participant)
        self.invited.discard(participant)

        server = origin_from_ucid(participant)
        self.servers.add(server)

        if not self.oldest_server:
            self.oldest_server = server
Ejemplo n.º 5
0
 def add_invited(self, invitee):
     """Someone has been invited to the room"""
     self.invited.add(invitee)
     self.servers.add(origin_from_ucid(invitee))
Ejemplo n.º 6
0
 def add_invited(self, invitee):
     """ Someone has been invited to the room
     """
     self.invited.add(invitee)
     self.servers.add(origin_from_ucid(invitee))