Esempio n. 1
0
def main():
    logger.info("Python: {}".format(platform.python_version()))
    if sys.argv[1] == "--init":
        logger.debug("Initializing gauge project.")
        copy_skel_files()
    else:
        load_implementations()
        start()
Esempio n. 2
0
def start():
    if environ.get('DEBUGGING'):
        debugpy.listen(('127.0.0.1', int(environ.get('DEBUG_PORT'))))
        print(ATTACH_DEBUGGER_EVENT)
        t = Timer(int(environ.get("debugger_wait_time", 30)), _handle_detached)
        t.start()
        debugpy.wait_for_client()
        t.cancel()
    logger.debug('Starting grpc server..')
    server = grpc.server(ThreadPoolExecutor(max_workers=1))
    p = server.add_insecure_port('127.0.0.1:0')
    handler = handlers.GrpcServiceHandler(server)
    spg.add_RunnerServicer_to_server(handler, server)
    logger.info('Listening on port:{}'.format(p))
    server.start()
    t = threading.Thread(name="listener", target=handler.wait_for_kill_event)
    t.start()
    t.join()
    os._exit(0)
Esempio n. 3
0
def copy_skel_files():
    try:
        logger.info('Initialising Gauge Python project')
        logger.info('create  {}'.format(env_dir))
        os.makedirs(env_dir)
        logger.info('create  {}'.format(impl_dirs[0]))
        shutil.copytree(os.path.join(SKEL, path.basename(impl_dirs[0])),
                        impl_dirs[0])
        logger.info('create  {}'.format(
            os.path.join(env_dir, PYTHON_PROPERTIES)))
        shutil.copy(os.path.join(SKEL, PYTHON_PROPERTIES), env_dir)
        f = open(requirements_file, 'w')
        f.write('getgauge==' + _get_version())
        f.close()
    except:
        logger.fatal(
            'Exception occurred while copying skel files.\n{}.'.format(
                traceback.format_exc()))
Esempio n. 4
0
def _handle_detached():
    logger.info("No debugger attached. Stopping the execution.")
    os._exit(1)