예제 #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)})
예제 #2
0
파일: web.py 프로젝트: keios/PyRfK
 def try_kick():
     try:
         li = LiquidInterface()
         li.connect()
         li.kick_harbor()
         li.close()
         return True
     except:
         return False
예제 #3
0
파일: web.py 프로젝트: alphabernd/PyRfK
 def try_kick():
     try:
         li = LiquidInterface()
         li.connect()
         li.kick_harbor()
         li.close()
         return True
     except:
         return False
예제 #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
예제 #5
0
파일: admin.py 프로젝트: polarbernd/PyRfK
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)})
예제 #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
예제 #7
0
파일: admin.py 프로젝트: alphabernd/PyRfK
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)})
예제 #8
0
파일: admin.py 프로젝트: alphabernd/PyRfK
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)})
예제 #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
예제 #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
예제 #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