Beispiel #1
0
def liquidsoap_status():
    try:
        ret = {}
        li = LiquidInterface()
        li.connect()
        ret['version'] = li.get_version()
        ret['uptime'] = li.get_uptime()
        ret['sources'] = []
        for source in li.get_sources():
            ret['sources'].append({
                'handler':
                source.handler,
                'type':
                source.type,
                'status': (source.status() != 'no source client connected'),
                'status_msg':
                source.status()
            })

        ret['sinks'] = []
        for sink in li.get_sinks():
            ret['sinks'].append({
                'handler': sink.handler,
                'type': sink.type,
                'status': (sink.status() == 'on')
            })
        li.close()
        return jsonify(ret)
    except Exception as e:
        return jsonify({'error': str(e)})
Beispiel #2
0
 def try_kick():
     try:
         li = LiquidInterface()
         li.connect()
         li.kick_harbor()
         li.close()
         return True
     except:
         return False
Beispiel #3
0
 def try_kick():
     try:
         li = LiquidInterface()
         li.connect()
         li.kick_harbor()
         li.close()
         return True
     except:
         return False
Beispiel #4
0
def kick():
    """Shorthand method for kicking the currently connected user
    
    returns True if someone was kicked
    returns False if harbor was empty or kick failed
    """

    logger.info('kick: trying to kick source')
    liquidsoap = LiquidInterface()
    liquidsoap.connect()
    kicked = liquidsoap.kick_harbor()
    liquidsoap.close()
    logger.info('kick: result is %s' % kicked)
    return kicked
Beispiel #5
0
def endpoint_action(action):
    if request.args.get('endpoint') is None:
        return jsonify({'error': 'no endpoint supplied!'})
    try:
        ret = {}
        li = LiquidInterface()
        li.connect()
        ret['status'] = li.endpoint_action(
            request.args.get('endpoint').encode('ascii', 'ignore'),
            action.encode('ascii', 'ignore'))
        li.close()
        return jsonify(ret)
    except Exception as e:
        return jsonify({'error': str(e)})
Beispiel #6
0
def kick():
    """shorthand method for kicking the currently connected user
    
    returns True if someone was kicked  
    """
    liquidsoap = LiquidInterface()
    liquidsoap.connect()
    kicked = False
    for source in liquidsoap.get_sources():
        if source.status() != 'no source client connected':
            source.kick()
            kicked = True
    liquidsoap.close()
    return kicked
Beispiel #7
0
def liquidsoap_status():
    try:
        ret = {}
        li = LiquidInterface()
        li.connect()
        ret['version'] = li.get_version()
        ret['uptime'] = li.get_uptime()
        ret['sources'] = []
        for source in li.get_sources():
            ret['sources'].append({'handler': source.handler,
                                   'type': source.type,
                                   'status': (source.status() != 'no source client connected'),
                                   'status_msg':source.status()})
            
        ret['sinks'] = []
        for sink in li.get_sinks():
            ret['sinks'].append({'handler': sink.handler,
                                   'type': sink.type,
                                   'status': (sink.status() == 'on')})
        li.close()
        return jsonify(ret)
    except Exception as e:
        return jsonify({'error': str(e)})
Beispiel #8
0
def endpoint_action(action):
    if request.args.get('endpoint') is None:
        return jsonify({'error':'no endpoint supplied!'})
    try:
        ret = {}
        li = LiquidInterface()
        li.connect()
        ret['status'] = li.endpoint_action(request.args.get('endpoint').encode('ascii','ignore'),
                                           action.encode('ascii','ignore'))
        li.close()
        return jsonify(ret)
    except Exception as e:
        return jsonify({'error': str(e)})
Beispiel #9
0
def kick():
    """Shorthand method for kicking the currently connected user

    Returns True if someone was kicked successfully
    Returns False if harbor was empty or the kick failed
    """

    # TODO: kick() should also create a time ban, otherwise the kicked client can reconnect immediately.
    # NOTE: Maybe we can create a global helper for this, as this may be helpful elsewhere.

    logger.info('kick: trying to kick source')
    liquidsoap = LiquidInterface()
    liquidsoap.connect()
    kicked = liquidsoap.kick_harbor()
    liquidsoap.close()
    logger.info('kick: result is %s' % kicked)
    return kicked
Beispiel #10
0
def kick():
    """Shorthand method for kicking the currently connected user
    
    returns True if someone was kicked
    returns False if harbor was empty or kick failed
    """

    logger.info('kick: trying to kick source')
    liquidsoap = LiquidInterface()
    liquidsoap.connect()
    kicked = liquidsoap.kick_harbor()
    liquidsoap.close()
    logger.info('kick: result is %s' % kicked)
    return kicked
Beispiel #11
0
def kick():
    """shorthand method for kicking the currently connected user
    
    returns True if someone was kicked  
    """
    liquidsoap = LiquidInterface()
    liquidsoap.connect()
    kicked = False
    for source in liquidsoap.get_sources():
        if source.status() != 'no source client connected':
            source.kick()
            kicked = True
    liquidsoap.close()
    return kicked