コード例 #1
0
ファイル: avocado-setup.py プロジェクト: harihare/tests
def env_check(enable_kvm):
    """
    Check if the environment is proper
    """
    logger.info("Check for environment")
    # create a folder to store all edited multiplexer files
    if not os.path.isdir("/tmp/mux/"):
        logger.info("Creating temporary mux dir")
        os.makedirs("/tmp/mux/")
    not_found = []
    (env_ver, env_type, cmd_pat) = helper.get_env_type(enable_kvm)
    # try to check base packages using major version numbers
    env_ver = env_ver.split('.')[0]
    env_deps = []
    if not CONFIGFILE.has_section('deps_%s' % env_ver):
        # Fallback to base name if specific version is not found
        dist = helper.get_dist()
        env_ver = dist[0]

    if CONFIGFILE.has_section('deps_%s' % env_ver):
        packages = CONFIGFILE.get('deps_%s' % env_ver, 'packages')
        if packages != '':
            env_deps = packages.split(',')
    for dep in env_deps:
        if helper.runcmd(cmd_pat % dep, ignore_status=True)[0] != 0:
            not_found.append(dep)

    env_deps = []
    # try to check env specific packages
    if CONFIGFILE.has_section('deps_%s_%s' % (env_ver, env_type)):
        packages = CONFIGFILE.get('deps_%s_%s' % (env_ver, env_type),
                                  'packages')
        if packages != '':
            env_deps = packages.split(',')
    for dep in env_deps:
        if helper.runcmd(cmd_pat % dep, ignore_status=True)[0] != 0:
            not_found.append(dep)
    if not_found:
        if args.no_deps_check:
            logger.warning(
                "No dependancy check flag is set, proceeding with bootstrap")
            logger.info("Please install following "
                        "dependancy packages %s", " ".join(not_found))
        elif args.install_deps:
            logger.warning("Installing missing packages %s",
                           " ".join(not_found))
            if helper.install_packages(not_found):
                logger.error("Some packages not installed")
                sys.exit(1)
        else:
            logger.error("Please install following "
                         "dependancy packages %s", " ".join(not_found))
            sys.exit(1)
コード例 #2
0
def env_check(enable_kvm):
    """
    Check if the environment is proper
    """
    logger.info("Check for environment")
    not_found = []
    (env_ver, env_type, cmd_pat) = helper.get_env_type(enable_kvm)
    # try to check base packages using major version numbers
    env_ver = env_ver.split('.')[0]
    env_deps = []
    if not CONFIGFILE.has_section('deps_%s' % env_ver):
        # Fallback to base name if specific version is not found
        dist = helper.get_dist()
        env_ver = dist[0]

    if CONFIGFILE.has_section('deps_%s' % env_ver):
        packages = CONFIGFILE.get('deps_%s' % env_ver, 'packages')
        if packages != '':
            env_deps = packages.split(',')
    for dep in env_deps:
        if helper.runcmd(cmd_pat % dep, ignore_status=True)[0] != 0:
            not_found.append(dep)

    env_deps = []
    # try to check env specific packages
    if CONFIGFILE.has_section('deps_%s_%s' % (env_ver, env_type)):
        packages = CONFIGFILE.get('deps_%s_%s' % (env_ver, env_type),
                                  'packages')
        if packages != '':
            env_deps = packages.split(',')
    for dep in env_deps:
        if helper.runcmd(cmd_pat % dep, ignore_status=True)[0] != 0:
            not_found.append(dep)
    if not_found:
        if args.install_deps:
            logger.warning("Installing missing packages %s",
                           " ".join(not_found))
            if helper.install_packages(not_found):
                logger.error("Some packages not installed")
                sys.exit(1)
        else:
            logger.error("Please install following "
                         "dependancy packages %s", " ".join(not_found))
            sys.exit(1)