How to use hardware - 10 common examples

To help you get started, we’ve selected a few hardware examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Antergos / Cnchi / test / test_hardware_module.py View on Github external
def test():
    """ Main function """
    locale_code, _encoding = locale.getdefaultlocale()
    lang = gettext.translation(APP_NAME, LOCALE_DIR, [locale_code], None, True)
    lang.install()

    setup_logging()

    # Get packages needed for detected hardware
    import hardware.hardware as hardware

    hardware_install = hardware.HardwareInstall("/usr/share/cnchi/src/hardware/modules")
    hardware_pkgs = hardware_install.get_packages()
    print("Hardware module added these packages : ", hardware_pkgs)
github ReliaQualAssociates / ramstk / tests / unit / hardware / TestResistor.py View on Github external
def setUp(self):
        """
        Setup the test fixture for the Resistor class.
        """

        self.DUT = Model()

        self._base_values = (0, 32, 'Alt Part #', 'Attachments', 'CAGE Code',
                             'Comp Ref Des', 0.0, 0.0, 0.0, 'Description',
                             100.0, 0, 0, 'Figure #', 50.0, 'LCN', 1, 0, 10.0,
                             'Name', 'NSN', 0, 'Page #', 0, 0, 'Part #', 1,
                             'Ref Des', 1.0, 0, 'Remarks', 0.0, 'Spec #', 0,
                             30.0, 30.0, 0.0, 2014)  # 0 - 37
        self._stress_values = (1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0,
                               1.0, 0.0, 1.0)  # 38 - 49
        self._rel_values = (0.0, 1.0, 1.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0,
                            0.0, 0.0, 1, 0.0, '', 0.0, 0.0, 0.0, 1, 0.0, 0.0,
                            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
                            1.0, 1.0, 0.0, 0.0, 0)  # 50 - 86
        self._user_values = (
            0.0, 1.0, 2.0, 30.0, 440.0, 5, 6, 7.0, 8.0, 99.0, 10.0, 11, 12,
            13.0, 14, 15.0, 16.0, 17.0, 18, 19.0, 0.0, 1.0, 2, 3, 440.0, 50,
github ReliaQualAssociates / ramstk / tests / unit / TestHardwareComponent.py View on Github external
def setUp(self):
        """
        Setup the test fixture for the Component class.
        """

        _database = '/home/andrew/projects/RTKTestDB.rtk'
        self._dao = _dao(_database)

        self.DUT = Model()

        self._base_values = (0, 32, 'Alt Part #', 'Attachments', 'CAGE Code',
                             'Comp Ref Des', 0.0, 0.0, 0.0, 'Description',
                             100.0, 0, 0, 'Figure #', 50.0, 'LCN', 1, 0, 10.0,
                             'Name', 'NSN', 0, 'Page #', 0, 0, 'Part #', 1,
                             'Ref Des', 1.0, 0, 'Remarks', 0.0, 'Spec #', 0,
                             30.0, 30.0, 0.0, 2014)
        self._stress_values = (1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0,
                               1.0, 0.0, 1.0)
        self._rel_values = (0.0, 1.0, 1.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0,
                            0.0, 0.0, 1, 0.0, '', 0.0, 0.0, 0.0, 1, 0.0, 0.0,
                            0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
                            1.0, 1.0, 0.0, 0.0, 0)
        self._user_values = (0.0, 1.0, 2.0, 30.0, 440.0, 5, 6, 7.0, 8.0, 99.0,
                             10.0, 11, 12, 13.0, 14, 15.0, 16.0, 17.0, 18,
                             19.0, 0.0, 1.0, 2, 3, 440.0, 50, 60, 7.0, 80.0,
github ReliaQualAssociates / ramstk / tests / unit / TestHardwareComponent.py View on Github external
def test_create(self):
        """
        (TestComponent) __init__ should return an Component model
        """

        self.assertTrue(isinstance(self.DUT, Model))

        # Properly sources the Hardware class.
        self.assertEqual(self.DUT.revision_id, None)

        # Scalar values are correct.
        self.assertEqual(self.DUT.category_id, 0)
        self.assertEqual(self.DUT.subcategory_id, 0)
        self.assertEqual(self.DUT.junction_temperature, 0.0)
        self.assertEqual(self.DUT.knee_temperature, 30.0)
        self.assertEqual(self.DUT.thermal_resistance, 0.0)
        self.assertEqual(self.DUT.reference_temperature, 30.0)
github ReliaQualAssociates / ramstk / tests / unit / hardware / TestSemiconductor.py View on Github external
def setUp(self):
        """
        Setup the test fixture for the Semiconductor class.
        """

        _database = '/home/andrew/projects/RTKTestDB.rtk'
        self._dao = _dao(_database)

        self.DUT = Model()
github wright-group / PyCMDS / hardware / hardware.py View on Github external
def import_hardwares(ini_path, name, Driver, GUI, Hardware):
    ini = wt.kit.INI(ini_path)
    hardwares = []
    for section in ini.sections:
        if ini.read(section, 'enable'):
            # initialization arguments
            kwargs = collections.OrderedDict()
            for option in ini.get_options(section):
                if option in ['__name__', 'enable', 'model', 'serial', 'path']:
                    continue
                else:
                    kwargs[option] = ini.read(section, option)            
            model = ini.read(section, 'model')
            if model == 'Virtual':
                hardware = Hardware(Driver, kwargs, GUI, name=section, model='Virtual')
            else:
                path = os.path.abspath(ini.read(section, 'path'))
                fname = os.path.basename(path).split('.')[0]
                mod = imp.load_source(fname, path)
                cls = getattr(mod, 'Driver')
                gui = getattr(mod, 'GUI')
                serial = ini.read(section, 'serial')
                hardware = Hardware(cls, kwargs, gui, name=section, model=model, serial=serial)
            hardwares.append(hardware)
    gui = pw.HardwareFrontPanel(hardwares, name=name)
    advanced_gui = pw.HardwareAdvancedPanel(hardwares, gui.advanced_button)
    return hardwares, gui, advanced_gui
github ReliaQualAssociates / ramstk / rtk / hardware / BoM.py View on Github external
def load_component(self, attributes):
        """
        Method to load the correct Component based on the category and
        subcategory ID's.

        :param tuple attributes: the attributes of the component to load.
        :return: an instance of the appropriate Component class.
        :rtype: object
        """
        # TODO: Consider refactoring load_component; current McCabe Complexity metric = 12.
        # Select the correct component type and create an instance of it's
        # data model.
        if attributes[90] < 1 or attributes[91] < 1:
            _component = Component()
        elif attributes[90] == 1:
            _component = load_capacitor(attributes[91])
        elif attributes[90] == 2:
            _component = load_connection(attributes[91])
        elif attributes[90] == 3:
            _component = load_inductor(attributes[91])
        elif attributes[90] == 4:
            _component = load_integrated_circuit(attributes[91])
        elif attributes[90] == 5:
            _component = load_meter(attributes[91])
        elif attributes[90] == 6:
            _component = load_miscellaneous(attributes[91])
        elif attributes[90] == 7:
            _component = load_relay(attributes[91])
        elif attributes[90] == 8:
            _component = load_resistor(attributes[91])
github redhat-cip / hardware / hardware / infiniband.py View on Github external
def ib_global_info(card_drv):
    '''Return global info of a IB card in a python dict.

Take in argument a card_drv (ex: mlx4_0).
    '''
    global_card_info = {}
    ret, global_info = cmd('ibstat %s -s' % card_drv)
    if ret == 0:
        for line in global_info.split('\n'):
            re_dev = re.search('CA type: (.*)', line)
            if re_dev is not None:
                global_card_info['device_type'] = re_dev.group(1)
            re_nb_ports = re.search('Number of ports: (.*)', line)
            if re_nb_ports is not None:
                global_card_info['nb_ports'] = re_nb_ports.group(1)
            re_fw_ver = re.search('Firmware version: (.*)', line)
            if re_fw_ver is not None:
                global_card_info['fw_ver'] = re_fw_ver.group(1)
            re_hw_ver = re.search('Hardware version: (.*)', line)
            if re_hw_ver is not None:
                global_card_info['hw_ver'] = re_hw_ver.group(1)
            re_node_guid = re.search('Node GUID: (.*)', line)
            if re_node_guid is not None:
github redhat-cip / hardware / hardware / detect.py View on Github external
def parse_dmesg(hrdw):
    """Run dmesg and parse the output."""

    _, output = detect_utils.cmd("dmesg")
    for line in output.split('\n'):
        words = line.strip().split(" ")

        if words[0].startswith("[") and words[0].endswith("]"):
            words = words[1:]

        if not words:
            continue

        if "ahci" in words[0]:
            parse_ahci(hrdw, words)
github redhat-cip / hardware / hardware / infiniband.py View on Github external
def ib_card_drv():
    '''Return an array of IB device (ex: ['mlx4_0']).'''
    ret, output = cmd('ibstat -l')
    if ret == 0:
        # Use filter to omit empty item due to trailing newline.
        return list(filter(None, output.split('\n')))

    return []