def start_server(env=None):
    if env is None:
        env = os.environ
    configname = env.get(common.ENV_CONFIGNAME)
    if not configname:
        sys.exit('%s must be set.' % common.ENV_CONFIGNAME)
    config = configs.config_by_name(configname)

    handshake_endpoint = env.get(common.ENV_HANDSHAKE_ENDPOINT)
    if handshake_endpoint:
        sock, app_endpoint = _get_appsock_from_handshake(
            config, handshake_endpoint)
    else:
        app_endpoint = env.get(common.ENV_APP_ENDPOINT)
        if not app_endpoint:
            sys.exit('%s must be set if not using a handshake.'
                     % common.ENV_APP_ENDPOINT)
        sock = compat.MQ.socket(compat.MQ.REP)
        sock.bind(app_endpoint)

    logger = utils.logger(__name__, app_endpoint)
    exec_context = config.exec_context()
    keep_going = True
    logger.debug('Starting server loop.')
    while keep_going:
        recved = sock.recv()
        try:
            func, arg = config.loads(recved)
            logger.debug('recv: %s, %s', func, arg)
            code = common.SUCCESS
            value = None
            if func == 'exec':
                exec_context(exec_, arg)
            elif func == 'eval':
                value = exec_context(eval_, arg)
            elif func == 'close':
                keep_going = False
            else:
                code = common.INVALID_METHOD
                value = func
            response = {
                'code': code,
                'value': value
            }
        except Exception as ex:
            logger.debug('unhandled error occured!')
            response = {
                'code': common.UNHANDLED_ERROR,
                'errtype': ex.__class__.__name__,
                'traceback': ''.join(traceback.format_exc())
            }
        logger.debug('send: %s', response)
        sock.send(config.dumps(response))
    logger.debug('closing.')
    sock.close()
    logger.debug('server socket closed.')
Get flag value.
dataset/ETHPy150Open rgalanakis/dccautomation/dccautomation/server.py/start_server--crossover with--dataset/ETHPy150Open programa-stic/barf-project/barf/barf/analysis/codeanalyzer/codeanalyzer.py/GenericFlag.value