<commit_before>#!/usr/bin/python
#
# Copyright (C) Citrix Systems Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; version 2.1 only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import re
import util


def parse_fcoe_eth_info():
    fcoe_eth_info = {}
    # create a dictionary of rport to eth
    try:
        cmd = ['fcoeadm', '-l']
        regex = re.compile("eth[0-9]")
        for line in util.doexec(cmd)[1].split('\n'):
            if line.find("Interface") != -1:
                searchObj = regex.search(line, 0)
                if searchObj:
                    eth = searchObj.group()
                    util.SMlog("eth: %s" % eth)
            if line.find("rport") != -1:
                str1, str2 = line.split(":", 1)
                fcoe_eth_info[str2.strip()] = eth
                eth = ""
    except:
        pass

    return fcoe_eth_info

def parse_fcoe_port_name_info():
    fcoe_port_info = []
    try:
        cmd= ['fcoeadm', '-i']
        for line in util.doexec(cmd)[1].split('\n'):
            if line.find("Port Name") != -1:
                str1, str2 = line.split(":")
                str2 = str2.strip()
                port = int(str2,0)
                util.SMlog(" port is %d" % port)
                fcoe_port_info.append(port)
    except:
        pass

    return fcoe_port_info<commit_msg>CA-189699: Fix FC vs FCoE adapter detection<commit_after>#!/usr/bin/python
#
# Copyright (C) Citrix Systems Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation; version 2.1 only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

import re
import util
import glob
import os

SYSFS_NET_PATH='/sys/class/net'

def parse_fcoe_eth_info():
    fcoe_eth_info = {}
    # create a dictionary of rport to eth
    try:
        cmd = ['fcoeadm', '-l']
        regex = re.compile("eth[0-9]")
        for line in util.doexec(cmd)[1].split('\n'):
            if line.find("Interface") != -1:
                searchObj = regex.search(line, 0)
                if searchObj:
                    eth = searchObj.group()
                    util.SMlog("eth: %s" % eth)
            if line.find("rport") != -1:
                str1, str2 = line.split(":", 1)
                fcoe_eth_info[str2.strip()] = eth
                eth = ""
    except:
        pass

    return fcoe_eth_info

def parse_fcoe_port_name_info():
    fcoe_port_info = []
    fcoe_ports = glob.glob(os.path.join(SYSFS_NET_PATH, "eth*"))
    for port in fcoe_ports:
        try:
            cmd= ['fcoeadm', '-i', os.path.basename(port)]
            for line in util.doexec(cmd)[1].split('\n'):
                if line.find("Port Name") != -1:
                    str1, str2 = line.split(":")
                    str2 = str2.strip()
                    port = int(str2,0)
                    util.SMlog(" port is %d" % port)
                    fcoe_port_info.append(port)
                    break
        except:
            pass

    return fcoe_port_info
{'fraction_non_alphanumeric': 0.10554870530209617, 'fraction_numerical': 0.016769420468557335, 'mean_word_length': 2.1032899770466718, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2712098', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1187, 'n_words': 409}