Exemple #1
0
def test_crawl():
    sf = get_site_factory(prefix="crawl_", update_from_git=True, install_test_python_modules=False)
    site = sf.get_site("central")
    logger.info("Site %s is ready!", site.id)

    crawler = Crawler(site)
    crawler.crawl()
    crawler.report()
def main(args):
    if is_running_as_site_user():
        raise Exception()

    logger.info("===============================================")
    logger.info("Setting up site")
    logger.info("===============================================")

    version = os.environ.get("VERSION", CMKVersion.DAILY)
    sf = get_site_factory(prefix="int_",
                          update_from_git=version == "git",
                          install_test_python_modules=True)

    site = sf.get_existing_site("test")

    if os.environ.get("REUSE"):
        logger.info(
            "Reuse previously existing site in case it exists (REUSE=1)")
        if not site.exists():
            logger.info("Creating new site")
            site = sf.get_site("test")
        else:
            logger.info("Reuse existing site")
            site.start()
    else:
        if site.exists():
            logger.info("Remove previously existing site (REUSE=0)")
            site.rm()

        logger.info("Creating new site")
        site = sf.get_site("test")

    logger.info("Site %s is ready!", site.id)

    logger.info("===============================================")
    logger.info("Switching to site context")
    logger.info("===============================================")

    try:
        return _execute_as_site_user(site, args)
    finally:
        if _is_dockerized():
            if os.path.exists("/results"):
                shutil.rmtree("/results")
                os.mkdir("/results")

            with suppress(FileNotFoundError):
                shutil.copy(site.path("junit.xml"), "/results")

            with suppress(FileNotFoundError):
                shutil.copytree(site.path("var/log"), "/results/logs")
Exemple #3
0
def main(args):
    if is_running_as_site_user():
        raise Exception()

    logger.info("===============================================")
    logger.info("Setting up site")
    logger.info("===============================================")

    version = os.environ.get("VERSION", CMKVersion.DAILY)
    sf = get_site_factory(prefix="int_",
                          update_from_git=version == "git",
                          install_test_python_modules=True)

    site = sf.get_existing_site("test")

    if os.environ.get("REUSE"):
        logger.info("Reuse previously existing site in case it exists (REUSE=1)")
        if not site.exists():
            logger.info("Creating new site")
            site = sf.get_site("test")
        else:
            logger.info("Reuse existing site")
            site.start()
    else:
        if site.exists():
            logger.info("Remove previously existing site (REUSE=0)")
            site.rm()

        logger.info("Creating new site")
        site = sf.get_site("test")

    logger.info("Site %s is ready!", site.id)

    logger.info("===============================================")
    logger.info("Switching to site context")
    logger.info("===============================================")

    try:
        return _execute_as_site_user(site, args)
    finally:
        sf.save_results()
Exemple #4
0
def site(request):
    sf = get_site_factory(prefix="int_",
                          update_from_git=True,
                          install_test_python_modules=True)
    return sf.get_existing_site("test")