Look in /sys/class/board-info/ to determine the platform type.

    This can return 'ev3', 'evb', 'pistorms', 'brickpi', 'brickpi3' or 'fake'.
332331
def get_current_platform():
    
    board_info_dir = '/sys/class/board-info/'

    if not os.path.exists(board_info_dir) or os.environ.get("FAKE_SYS"):
        return 'fake'

    for board in os.listdir(board_info_dir):
        uevent_filename = os.path.join(board_info_dir, board, 'uevent')

        if os.path.exists(uevent_filename):
            with open(uevent_filename, 'r') as fh:
                for line in fh.readlines():
                    (key, value) = line.strip().split('=')

                    if key == 'BOARD_INFO_MODEL':

                        if value == 'LEGO MINDSTORMS EV3':
                            return 'ev3'

                        elif value in ('FatcatLab EVB', 'QuestCape'):
                            return 'evb'

                        elif value == 'PiStorms':
                            return 'pistorms'

                        # This is the same for both BrickPi and BrickPi+.
                        # There is not a way to tell the difference.
                        elif value == 'Dexter Industries BrickPi':
                            return 'brickpi'

                        elif value == 'Dexter Industries BrickPi3':
                            return 'brickpi3'

                        elif value == 'FAKE-SYS':
                            return 'fake'

    return None
372691
function findOS(uaPlatformInfo) {
  var oses = ['Android', 'BSD', 'Linux', 'Windows', 'iPhone OS', 'Mac OS', 'BSD', 'CrOS', 'Darwin', 'Dragonfly', 'Fedora', 'Gentoo', 'Ubuntu', 'debian', 'HP-UX', 'IRIX', 'SunOS', 'Macintosh', 'Win 9x', 'Win98', 'Win95', 'WinNT'];
  for(var os in oses) {
    for(var i in uaPlatformInfo) {
      var item = uaPlatformInfo[i];
      if (contains(item, oses[os])) return item;
    }
  }
  return 'Other';
}
862969
def terminal_type(cls):
        
        what = sys.platform

        kind = 'UNDEFINED_TERMINAL_TYPE'
        if 'linux' in what:
            kind = 'linux'
        elif 'darwin' in what:
            kind = 'darwin'
        elif 'cygwin' in what:
            kind = 'cygwin'
        elif 'windows' in what:
            kind = 'windows'

        return kind
186560
def getPlatformInfo():
  """"""
  if "linux" in sys.platform:
    platform = "linux"
  elif "darwin" in sys.platform:
    platform = "darwin"
  # win32
  elif sys.platform.startswith("win"):
    platform = "windows"
  else:
    raise Exception("Platform '%s' is unsupported!" % sys.platform)
  return platform
848276
def device_info(self):
        
        # get hostname, model, and version from 'show version'
        resp = self._session.get_software_information(format='xml')

        hostname = resp.xpath('//software-information/host-name')[0].text
        model = resp.xpath('//software-information/product-model')[0].text

        version = 'Unknown'
        if resp.xpath('//junos-version'):
            """ case:
                <junos-version>15.1</junos-version>
            """
            try:
                version = resp.xpath('//junos-version')[0].text
            except IndexError:
                pass
        elif resp.xpath("//package-information[name = 'junos-version']"):
            """ case:
                <package-information>
                    <name>junos-version</name>
                    <comment>Junos: 14.2R4</comment>
                </package-information>
           """
            try:
                version = (resp.xpath(
                    "//package-information[name = 'junos-version']/comment"
                    )[0].text).split()[1]
            except IndexError:
                pass
        else:
            """ case:
                <package-information>
                    <name>junos</name>
                    <comment>JUNOS Base OS boot [12.3R5]</comment>
                </package-information>
            """
            try:
                version = ((resp.xpath(
                    '//software-information/package-information/comment'
                    )[0].text.split('[')[1].split(']')[0]))
            except IndexError:
                pass

        # try looking for 'junos-version' for >= 14.2
#        for element in resp.xpath('//software-information'):
#            version = element.findtext('junos-version')

#        if not version:
#            try:
#                version = ((resp.xpath(
#                    '//software-information/package-information/comment')
#                    [0].text.split('[')[1].split(']')[0]))
#            except IndexError:
#                version = 'Unknown'

        # get uptime from 'show system uptime'
        resp = self._session.get_system_uptime_information(format='xml')
        try:
            current_time = resp.xpath('//current-time/date-time')[0].text
        except IndexError:
            current_time = 'Unknown'
        try:
            uptime = resp.xpath('//uptime-information/up-time')[0].text
        except IndexError:
            uptime = 'Unknown'
        # get serial number from 'show chassis hardware'
        show_hardware = self._session.get_chassis_inventory(format='xml')
        # If we're hitting an EX, grab each Routing Engine Serial number
        # to get all RE SNs in a VC
        try:
            chassis_module = show_hardware.xpath(
                '//chassis-inventory/chassis/chassis-module/description'
                )[0].text
        except IndexError:
            chassis_module = 'Unknown'

        if ('EX' or 'ex' or 'Ex') in chassis_module:
            serial_num = ''
            for eng in show_hardware.xpath(
                    '//chassis-inventory/chassis/chassis-module'):
                if 'Routing Engine' in eng.xpath('name')[0].text:
                    serial_num += (eng.xpath('name')[0].text + ' Serial #: ' +
                                   eng.xpath('serial-number')[0].text)
        else:  # Any other device type, just grab chassis SN
            try:
                serial_num = ('Chassis Serial Number: ' + show_hardware.xpath(
                    '//chassis-inventory/chassis/serial-number')[0].text)
            except IndexError:
                serial_num = 'Chassis Serial Number: ' \
                    + 'Unknown (virtual machine?)'
        return ('Hostname: %s\nModel: %s\nJunos Version: %s\n%s\nCurrent Time:'
                ' %s\nUptime: %s\n' %
                (hostname, model, version, serial_num, current_time, uptime))
1067924
def systemInformationType17():
    """"""
    a = L2PseudoLength(l2pLength=0x01)
    b = TpPd(pd=0x6)
    c = MessageType(mesType=0x3e)  # 00111110
    d = Si17RestOctets()
    packet = a / b / c / d
    return packet
47662
def get_type(cls, result_name):
        
        if result_name == "Alarm":
            return cls.ALARM
        elif result_name == "Log Message":
            return cls.LOG
        elif result_name == "Error Message":
            return cls.ERROR
        elif result_name == "Host Detail":
            return cls.HOST_DETAIL
        else:
            assert False, "Erroneous result name {0}.".format(result_name)
948220
def auto_name_prefix(self):
        
        # if the platform is not native, auto_name would clobber native downloads.
        # make a prefix to avoid this
        native_system = std_platform.system()
        native_machine = self.CPU_ALIASES.get(std_platform.machine(), std_platform.machine())
        if native_system == self.system and native_machine == self.machine:
            return ''
        platform = {
            'linux': 'linux32',
            'android-api-16': 'android-arm',
            'android-aarch64': 'android-arm64',
        }.get(self.gecko_platform, self.gecko_platform)
        return platform + '-'
350528
def get_platform():
    """'"""
    # XXX remove distutils dependency
    result = distutils.util.get_platform().replace('.', '_').replace('-', '_')
    if result == "linux_x86_64" and sys.maxsize == 2147483647:
        # pip pull request #3497
        result = "linux_i686"
    return result
556576
def is_unix(name=None):
        
        name = name or sys.platform
        return Platform.is_darwin(name) or Platform.is_linux(name) or Platform.is_freebsd(name)
1344350
def get_platform():
        """"""
        _sys_map = {'linux2': 'linux', 'linux': 'linux',
                    'darwin': 'osx', 'win32': 'win', 'openbsd5': 'openbsd'}

        non_x86_linux_machines = {'armv6l', 'armv7l', 'ppc64le'}
        sys_platform = _sys_map.get(sys.platform, 'unknown')
        bits = 8 * tuple.__itemsize__

        if (sys_platform == 'linux' and
                platform.machine() in non_x86_linux_machines):
            arch_name = platform.machine()
            subdir = 'linux-{0}'.format(arch_name)
        else:
            arch_name = {64: 'x86_64', 32: 'x86'}[bits]
            subdir = '{0}-{1}'.format(sys_platform, bits)

        return subdir
809322
def system_types():
    '''
    
    '''
    ret = {}
    for line in __salt__['cmd.run']('sfdisk -T').splitlines():
        if not line:
            continue
        if line.startswith('Id'):
            continue
        comps = line.strip().split()
        ret[comps[0]] = comps[1]
    return ret
515969
def _linux_id(self):
        """"""
        linux_id = None

        hardware = self.detector.get_cpuinfo_field("Hardware")

        if hardware is None:
            vendor_id = self.detector.get_cpuinfo_field("vendor_id")
            if vendor_id in ("GenuineIntel", "AuthenticAMD"):
                linux_id = GENERIC_X86

            compatible = self.detector.get_device_compatible()
            if compatible and 'tegra' in compatible:
                if 'cv' in compatible or 'nano' in compatible:
                    linux_id = T210
                elif 'quill' in compatible:
                    linux_id = T186
                elif 'xavier' in compatible:
                    linux_id = T194
        elif hardware in ("BCM2708", "BCM2709", "BCM2835"):
            linux_id = BCM2XXX
        elif "AM33XX" in hardware:
            linux_id = AM33XX
        elif "sun8i" in hardware:
            linux_id = SUN8I
        elif "ODROIDC" in hardware:
            linux_id = S805
        elif "ODROID-C2" in hardware:
            linux_id = S905
        elif "SAMA5" in hardware:
            linux_id = SAMA5

        return linux_id
986046
def systemInformationType7():
    """"""
    a = L2PseudoLength(l2pLength=0x01)
    b = TpPd(pd=0x6)
    c = MessageType(mesType=0x37)  # 000110111
    d = Si7RestOctets()
    packet = a / b / c / d
    return packet
196075
def detectSymbianOS(self):
        
        return UAgentInfo.deviceSymbian in self.__userAgent \
            or UAgentInfo.deviceS60 in self.__userAgent \
            or UAgentInfo.deviceS70 in self.__userAgent \
            or UAgentInfo.deviceS80 in self.__userAgent \
            or UAgentInfo.deviceS90 in self.__userAgent
223201
def device_info(device):
    """"""

    status = subprocess.check_output([
        'ibstat', device, '-s']).splitlines()

    regexes = {
        "CA type: (.*)": "device_type",
        "Number of ports: (.*)": "num_ports",
        "Firmware version: (.*)": "fw_ver",
        "Hardware version: (.*)": "hw_ver",
        "Node GUID: (.*)": "node_guid",
        "System image GUID: (.*)": "sys_guid",
    }

    device = DeviceInfo()

    for line in status:
        for expression, key in regexes.items():
            matches = re.search(expression, line)
            if matches:
                setattr(device, key, matches.group(1))

    return device
529272
def type(self):
        
        if self._device_mode == 1 or self._type == CertificateType.developer:
            return CertificateType.developer
        elif self._type == CertificateType.bootstrap:
            return CertificateType.bootstrap
        else:
            return CertificateType.lwm2m