How to use the hardware.hardware.Hardware function in hardware

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 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 Antergos / Cnchi / src / hardware / nvidia.py View on Github external
#
#  You should have received a copy of the GNU 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.

""" Nvidia driver installation """

from hardware.hardware import Hardware
import os

from nvidia_db import DEVICES

CLASS_NAME = "NVidia"

class NVidia(Hardware):
    def __init__(self):
        self.ARCH = os.uname()[-1]

    def get_packages(self):
        pkgs = ["nvidia", "libva-vdpau-driver"]
        if self.ARCH == "x86_64":
            pkgs.append("lib32-nvidia-libgl")

    def post_install(self, dest_dir):
        path = "%s/etc/X11/xorg.conf.d/10-nvidia.conf" % dest_dir
        with open(path, 'w') as video:
            video.write('Section "Device"\n')
            video.write('\tIdentifier     "Device0"\n')
            video.write('\tDriver         "nvidia"\n')
            video.write('\tOption         "NoLogo"\n')
            video.write('\tOption         "RegistryDwords"      "EnableBrightnessControl=1"\n')
github wright-group / PyCMDS / hardware / opas / opas.py View on Github external
# finish
        layout.addWidget(button_container)
        return [button1, button2]
        
    def on_home(self):
        self.driver.hardware.q.push('home_motor', [self.motor_name])
    
    def on_set(self):
        destination = self.destination.read()
        self.hardware.set_motor(self.motor_name, destination)


### hardware ##################################################################


class Hardware(hw.Hardware):
    
    def __init__(self, *arks, **kwargs):
        self.kind = 'OPA'
        hw.Hardware.__init__(self, *arks, **kwargs)

    @property
    def curve(self):
        # TODO: a more thread-safe operation (copy?)
        return self.driver.curve
    
    @property
    def curve_paths(self):
        """
        OrderedDict {name: path}
        """
        # TODO: a more thread-safe operation
github Antergos / Cnchi / cnchi / hardware / catalyst.py View on Github external
"0x68e4", "0x68e5", "0x68e0", "0x68e1", "0x6720", "0x6721", "0x6724",
    "0x6725", "0x6764", "0x6765", "0x6761", "0x6760", "0x6763", "0x6741",
    "0x6740", "0x6744", "0x6745", "0x6742", "0x6743", "0x6820", "0x6821",
    "0x6824", "0x6825", "0x6830", "0x6823", "0x6826", "0x6827", "0x682d",
    "0x682f", "0x6831", "0x682b", "0x6822", "0x682a", "0x6843", "0x6840",
    "0x6841", "0x6842", "0x6800", "0x6801", "0x6920", "0x6921", "0x6907",
    "0x6900", "0x6901", "0x6902", "0x6903", "0x6649", "0x6608", "0x68f1",
    "0x68e8", "0x68e9", "0x6888", "0x6889", "0x688d", "0x688c", "0x688a",
    "0x68a9", "0x6880", "0x68c8", "0x68c9", "0x6722", "0x6723", "0x6726",
    "0x6727", "0x6728", "0x6729", "0x6768", "0x6766", "0x6767", "0x6762",
    "0x6700", "0x6701", "0x6702", "0x6703", "0x6704", "0x6705", "0x6706",
    "0x6707", "0x6708", "0x6709", "0x6746", "0x6747", "0x6748", "0x6749",
    "0x674a", "0x6828", "0x682c", "0x6808", "0x684c", "0x6809", "0x6780",
    "0x6784", "0x6788", "0x678a", "0x692f", "0x692b", "0x6929", "0x68f2"]

class Catalyst(Hardware):
    def __init__(self):
        Hardware.__init__(self, CLASS_NAME, CLASS_ID, VENDOR_ID, DEVICES, PRIORITY, ENABLED)

    @staticmethod
    def get_packages():
        pkgs = ["catalyst-hook", "catalyst-libgl", "catalyst-utils", "acpid", "qt4"]
        if os.uname()[-1] == "x86_64":
            pkgs.extend(["lib32-catalyst-libgl", "lib32-catalyst-utils", "lib32-opencl-catalyst"])
        return pkgs

    @staticmethod
    def add_repositories(path):
        """ Adds [xorg116] and [catalyst] repos to pacman.conf """
        with open(path, 'r') as pacman_conf:
            lines = pacman_conf.readlines()
        with open(path, "w") as pacman_conf:
github Antergos / Cnchi / cnchi / hardware / vmware.py View on Github external
def post_install(dest_dir):
        """ Post install commands """
        Hardware.chroot(["systemctl", "enable", "vmtoolsd"], dest_dir)
github Antergos / Cnchi / src / hardware / modules / nvidia.py View on Github external
"0x11b7", "0x11b8", "0x11ba", "0x11bc", "0x11bd", "0x11be", "0x11bf",
    "0x11c0", "0x11c2", "0x11c3", "0x11c4", "0x11c5", "0x11c6", "0x11c8",
    "0x11e0", "0x11e1", "0x11e2", "0x11e3", "0x11fa", "0x11fc", "0x1200",
    "0x1201", "0x1203", "0x1205", "0x1206", "0x1207", "0x1208", "0x1210",
    "0x1211", "0x1212", "0x1213", "0x1241", "0x1243", "0x1244", "0x1245",
    "0x1246", "0x1247", "0x1248", "0x1249", "0x124b", "0x124d", "0x1251",
    "0x1280", "0x1281", "0x1282", "0x1284", "0x1286", "0x1287", "0x1288",
    "0x1289", "0x1290", "0x1291", "0x1292", "0x1293", "0x1295", "0x1296",
    "0x1298", "0x1299", "0x12b9", "0x12ba", "0x1340", "0x1341", "0x1346",
    "0x1347", "0x1380", "0x1381", "0x1382", "0x1390", "0x1391", "0x1392",
    "0x1393", "0x139a", "0x139b", "0x13b3", "0x13ba", "0x13bb", "0x13bc",
    "0x13c0", "0x13c2", "0x13d7", "0x13d8", "0x13d9", "0x1401", "0x17c2",
    "0x17f0", "0x1140", "0x1b80"]


class Nvidia(Hardware):
    """ Nvidia proprietary graphics driver """

    def __init__(self):
        Hardware.__init__(self, CLASS_NAME, CLASS_ID,
                          VENDOR_ID, DEVICES, PRIORITY)

    @staticmethod
    def get_packages():
        """ Get all required packages """
        pkgs = ["nvidia", "libvdpau"]
        if os.uname()[-1] == "x86_64":
            pkgs.extend(["lib32-nvidia-utils", "lib32-libvdpau"])
        return pkgs

    @staticmethod
    def get_conflicts():
github wright-group / PyCMDS / hardware / spectrometers / spectrometers.py View on Github external
self.hardware_ini = ini
        hw.Driver.__init__(self, *args, **kwargs)
        self.limits.write(0., 10000.)


### gui #######################################################################


class GUI(hw.GUI):
    pass


### hardware ##################################################################


class Hardware(hw.Hardware):
    
    def __init__(self, *args, **kwargs):
        self.kind = 'spectrometer'
        hw.Hardware.__init__(self, *args, **kwargs)


### import ####################################################################


ini_path = os.path.join(directory, 'spectrometers.ini')
hardwares, gui, advanced_gui = hw.import_hardwares(ini_path, name='Spectrometers', Driver=Driver, GUI=GUI, Hardware=Hardware)
github wright-group / PyCMDS / hardware / delays / delays.py View on Github external
def __init__(self, *arks, **kwargs):
        self.kind = 'delay'        
        self.factor = pc.Number(1, decimals=0)
        self.motor_limits = pc.NumberLimits(min_value=0, max_value=50, units='mm')
        self.motor_position = pc.Number(units='mm', display=True, limits=self.motor_limits)        
        self.zero_position = pc.Number(display=True)
        hw.Hardware.__init__(self, *arks, **kwargs)
        self.label = pc.String(self.name, display=True)
github Antergos / Cnchi / src / hardware / modules / fingerprint.py View on Github external
def __init__(self):
        Hardware.__init__(self, CLASS_NAME, CLASS_ID, VENDOR_ID, DEVICES)