Ejemplo n.º 1
0
def action_status(options, irc_manager):
    connection = options.irc_connection
    try:
        if connection == 'all':
            status = irc_manager.status_all()
        else:
            status = irc_manager.status(connection)
    except ValueError as e:
        console('ERROR: %s' % e.args[0])
        return

    header = [
        'IRC Connection', 'Thread', 'Channels', 'Connected Channels', 'Server'
    ]
    table_data = [header]
    for name, info in status.items():
        table_data.append([
            name, info['thread'], ', '.join(info['channels']),
            ', '.join(info['connected_channels']),
            '%s:%s' % info['server']
        ])
    table = TerminalTable(options.table_type, table_data)
    try:
        console(table.output)
    except TerminalTableError as e:
        console('ERROR: %s' % e)
Ejemplo n.º 2
0
def action_status(options, irc_manager):
    connection = options.irc_connection
    try:
        status = irc_manager.status(connection)
    except ValueError as e:
        console('ERROR: %s' % e.args[0])
        return

    header = ['Name', 'Alive', 'Channels', 'Server']
    table_data = [header]

    for connection in status:
        for name, info in connection.items():
            alive = colorize('green', 'Yes') if info['alive'] else colorize('red', 'No')
            channels = []
            for channel in info['channels']:
                for channel_name, channel_status in channel.items():
                    channels.append(channel_name)
                    if channel_status == IRCChannelStatus.CONNECTED:
                        channels[-1] = colorize('green', '* ' + channels[-1])
            table_data.append([name, alive, ', '.join(channels), '%s:%s' % (info['server'], info['port'])])
    try:
        table = TerminalTable(options.table_type, table_data)
        console(table.output)
        console(colorize('green', ' * Connected channel'))
    except TerminalTableError as e:
        console('ERROR: %s' % e)
Ejemplo n.º 3
0
def action_status(options, irc_manager):
    connection = options.irc_connection
    try:
        if connection == 'all':
            status = irc_manager.status_all()
        else:
            status = irc_manager.status(connection)
    except ValueError as e:
        console('ERROR: %s' % e.args[0])
        return

    header = ['Name', 'Status', 'Channels', 'Server']
    table_data = [header]

    for name, info in status.items():
        channels = []
        for channel in info['channels'].keys():
            channels.append(channel)
            if channel in info['connected_channels']:
                channels[-1] = '*' + channels[-1]
        table_data.append([name, info['thread'], ', '.join(channels), '%s:%s' % info['server']])
    table = TerminalTable(options.table_type, table_data)
    try:
        console(table.output)
        console(' * Connected channel')
    except TerminalTableError as e:
        console('ERROR: %s' % e)
Ejemplo n.º 4
0
    def get(self, session=None):
        """Returns status of IRC connections"""
        from flexget.plugins.daemon.irc import irc_manager
        if irc_manager is None:
            raise BadRequest('IRC daemon does not appear to be running')

        args = irc_parser.parse_args()
        name = args.get('name')
        try:
            status = irc_manager.status(name)
        except ValueError as e:
            raise NotFoundError(e.args[0])
        return jsonify(status)
Ejemplo n.º 5
0
    def get(self, session=None):
        """Returns status of IRC connections"""
        from flexget.plugins.daemon.irc import irc_manager
        if irc_manager is None:
            raise BadRequest('IRC daemon does not appear to be running')

        args = irc_parser.parse_args()
        name = args.get('name')
        try:
            status = irc_manager.status(name)
        except ValueError as e:
            raise NotFoundError(e.args[0])
        return jsonify(status)
Ejemplo n.º 6
0
def action_status(options, irc_manager):
    connection = options.irc_connection
    try:
        if connection == 'all':
            status = irc_manager.status_all()
        else:
            status = irc_manager.status(connection)
    except ValueError as e:
        console('ERROR: %s' % e.args[0])
        return

    header = ['IRC Connection', 'Thread', 'Channels', 'Connected Channels', 'Server']
    table_data = [header]
    for name, info in status.items():
        table_data.append([name, info['thread'], ', '.join(info['channels']), ', '.join(info['connected_channels']),
                           '%s:%s' % info['server']])
    table = TerminalTable(options.table_type, table_data)
    try:
        console(table.output)
    except TerminalTableError as e:
        console('ERROR: %s' % e)