예제 #1
0
def print_ioc_list(epics_version_list):
    """
    List all the IOC's available in prod for the given EPICS version(s).
    :param epics_version_list: list of EPICS versions to search for IOC's
    :type epics_version_list: list
    :return: None
    """
    ioc_dict = {}
    len_max = 0

    # Loop over all EPICS versions and IOC's.
    # Build a dictionary where each entry is the list containing the different EPICS
    # version(s) for each IOC.
    # EPICS versions are listed in reverse order.
    for epics_version in sorted(epics_version_list, reverse=True):
        for ioc_name in get_ioc_list(epics_version, MATURITY_PROD):
            len_max = max(len_max, len(ioc_name))
            if ioc_name in ioc_dict:
                ioc_dict[ioc_name].append(epics_version)
            else:
                ioc_dict[ioc_name] = [epics_version]

    # Print the dictionary (formatted).
    format_string = '{0:' + str(len_max) + '}    {1}'
    for ioc_name in sorted(ioc_dict):
        print format_string.format(ioc_name, ioc_dict[ioc_name])
예제 #2
0
def print_ioc_dependency_report(ioc_name_list, exclude_list,
                                epics_version_list, csv_output):
    """
    Print a matrix (table) with the dependencies for each IOC.
    The match list can be used to select ioc's matching a list of substrings.
    The exclude list can be used to skip ioc's matching a list of substrings.

    Create a dictionary indexed by the tuple (name, version), where each
    element of the dictionary is a list of the dependencies for the given ioc.
    Only ioc's with MATURITY_PROD are considered since versions numbers
    don't make sense in maturities other than production.
    :param ioc_name_list: list of ioc names to include in the output
    :type ioc_name_list: list
    :param exclude_list: list of strings to match ioc names to exclude from the output
    :type exclude_list: list
    :param epics_version_list: list of EPICS versions to include in the output
    :type epics_version_list: list
    :param csv_output: CSV output?
    :type csv_output: bool
    :return:
    """
    for epics_version in epics_version_list:

        # List of all IOC (target) names for the EPICS version
        ioc_list = get_ioc_list(epics_version, MATURITY_PROD)

        # Loop over all ioc's, sites and versions for a given EPICS version.
        # Create a dictionary indexed by the tuple (ioc name, ioc version), where each
        # element of the dictionary is a list of the dependencies for the given ioc.
        # IOC's are "matched" and "excluded" at this point.
        dep_dict = {}
        for ioc_target_name in ioc_list:
            for site in SITE_LIST:
                for ioc_version in get_ioc_versions(ioc_target_name,
                                                    epics_version, site):
                    ioc_name = get_ioc_name(ioc_target_name, site)
                    if skip_name(ioc_name, ioc_name_list) or skip_exclude(
                            ioc_name, exclude_list):
                        continue
                    # print ioc_name, ioc_version
                    ioc = IOC(ioc_name)
                    ioc.set_attributes(MATURITY_PROD, epics_version, site,
                                       ioc_target_name, ioc_version)
                    # print ioc
                    dep_dict[(ioc_name,
                              ioc_version)] = ioc.get_ioc_dependencies()

        _print_dependency_report(dep_dict, epics_version, csv_output)

        if len(epics_list) > 1:
            print '\n'
예제 #3
0
def print_what_depends_report(support_name_list, epics_version_list):
    """
    List all support modules and ioc's that depend on one or more support modules.
    :param support_name_list: list of support names that modules depend on
    :type support_name_list: list
    :param epics_version_list: list of EPICS versions to include in the output
    :type epics_version_list: list
    :return:
    """
    ioc_dict = {}
    support_dict = {}
    len_max = 0

    # Loop over all available EPICS versions
    for epics_version in epics_version_list:

        # Support modules
        for support_name in get_support_module_list(epics_version, MATURITY_PROD):
            # if skip_name(support_name, support_name_list) or skip_exclude(support_name, exclude_list):
            #     continue
            for support_version in get_support_module_versions(support_name, epics_version):
                sup = SupportModule(support_name, support_version, epics_version, MATURITY_PROD)
                dep_names = [x.name for x in sup.get_support_module_dependencies()]
                # print dep_names
                for name in dep_names:
                    if name in support_name_list:
                        # support_set.add(support_name)
                        if support_name not in support_dict:
                            support_dict[support_name] = set()
                        support_dict[support_name].add(name)
                        len_max = max(len_max, len(support_name))
        # print support_dict

        # IOC's
        ioc_name_list = get_ioc_list(epics_version, MATURITY_PROD)
        for ioc_target_name in ioc_name_list:
            for site in SITE_LIST:
                for ioc_version in get_ioc_versions(ioc_target_name, epics_version, site):
                    ioc_name = get_ioc_name(ioc_target_name, site)
                    # print ioc_name, ioc_version
                    ioc = IOC(ioc_name)
                    ioc.set_attributes(MATURITY_PROD, epics_version, site, ioc_target_name, ioc_version)
                    dep_names = [x.name for x in ioc.get_ioc_dependencies()]
                    # print dep_names
                    for name in dep_names:
                        if name in support_name_list:
                            # support_set.add(support_name)
                            if ioc_target_name not in support_dict:
                                ioc_dict[ioc_target_name] = set()
                            ioc_dict[ioc_target_name].add(name)
                            len_max = max(len_max, len(ioc_target_name))
        # print ioc_dict

        # Format output
        format_string = ' ' * 3 + '{0:' + str(len_max) + '}    {1}'
        print epics_version
        for item in sorted(support_dict):
            print format_string.format(str(item), str(list(support_dict[item])))
        for item in sorted(ioc_dict):
            print format_string.format(str(item), str(list(ioc_dict[item])))
        if len(epics_version_list) > 1:
            print ''