How to use the hardware.hardware.HardwareInstall 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 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 Antergos / Cnchi / cnchi.tmp / cnchi / installation / select_packages.py View on Github external
# There're some English variants available but not all of them.
                lang_packs = ['en_gb']
                locale = self.settings.get('locale').split('.')[0].lower()
                if locale in lang_packs:
                    pkg_text = base_name + locale
            else:
                # All the other language packs use their language code
                lang_code = self.settings.get('language_code').lower()
                pkg_text = base_name + lang_code
            if pkg_text:
                logging.debug("Selected kde language pack: %s", pkg_text)
                self.packages.append(pkg_text)

        try:
            # Detect which hardware drivers are needed
            hardware_install = hardware.HardwareInstall(
                use_proprietary_graphic_drivers=self.settings.get('feature_graphic_drivers'))
            driver_names = hardware_install.get_found_driver_names()
            if driver_names:
                logging.debug(
                    "Hardware module detected these drivers: %s",
                    driver_names)

            # Add needed hardware packages to our list
            hardware_pkgs = hardware_install.get_packages()
            if hardware_pkgs:
                logging.debug(
                    "Hardware module added these packages: %s",
                    ", ".join(hardware_pkgs))
                if 'virtualbox' in hardware_pkgs:
                    self.vbox = True
                self.packages.extend(hardware_pkgs)
github Antergos / Cnchi / cnchi / installation / process.py View on Github external
os.mkdir(sudoers_dir, 0o710)
        sudoers_path = os.path.join(sudoers_dir, "10-installer")
        try:
            with open(sudoers_path, "w") as sudoers:
                sudoers.write('{0} ALL=(ALL) ALL\n'.format(username))
            os.chmod(sudoers_path, 0o440)
            logging.debug(_("Sudo configuration for user %s done."), username)
        except IOError as io_error:
            # Do not fail if can't write 10-installer file. Something bad must be happening, though.
            logging.error(io_error)

        # Configure detected hardware
        try:
            import hardware.hardware as hardware

            hardware_install = hardware.HardwareInstall()
            logging.debug(_("Running post-install scripts from hardware module..."))
            hardware_install.post_install(DEST_DIR)
        except ImportError:
            logging.warning(_("Can't import hardware module."))
        except Exception as general_error:
            logging.warning(_("Unknown error in hardware module. Output: %s"), general_error)

        # Setup user

        default_groups = 'lp,video,network,storage,wheel,audio'

        if self.vbox:
            # Why there is no vboxusers group? Add it ourselves.
            chroot_run(['groupadd', 'vboxusers'])
            default_groups += ',vboxusers,vboxsf'
            self.enable_services(["vboxservice"])
github Antergos / Cnchi / src / installation / select_packages.py View on Github external
def add_drivers(self):
        """ Add package drivers """
        try:
            # Detect which hardware drivers are needed
            hardware_install = hardware.HardwareInstall(
                self.settings.get('cnchi'),
                self.settings.get('feature_graphic_drivers'))
            driver_names = hardware_install.get_found_driver_names()
            if driver_names:
                logging.debug(
                    "Hardware module detected these drivers: %s",
                    driver_names)

            # Add needed hardware packages to our list
            hardware_pkgs = hardware_install.get_packages()
            if hardware_pkgs:
                logging.debug(
                    "Hardware module added these packages: %s",
                    ", ".join(hardware_pkgs))
                if 'virtualbox' in hardware_pkgs:
                    self.vbox = True
github Antergos / Cnchi / src / installation / process.py View on Github external
except subprocess.CalledProcessError as err:
            logging.error(err.output)
        except subprocess.TimeoutExpired as err:
            logging.error(err)

        if desktop != "nox":
            # Set lightdm config including autologin if selected
            self.set_display_manager()

        # Configure user features (third party software, libreoffice language pack, ...)
        self.setup_features()

        # Configure detected hardware
        try:
            import hardware.hardware as hardware
            hardware_install = hardware.HardwareInstall()
            logging.debug("Running post-install scripts from hardware module...")
            hardware_install.post_install(self.dest_dir)
        except ImportError:
            logging.warning(_("Can't import hardware module."))
        except Exception as err:
            logging.warning(_("Unknown error in hardware module. Output: %s") % err)

        # Encrypt user's home directory if requested
        # TODO: Test this!
        if self.settings.get('encrypt_home'):
            self.queue_event('debug', _("Encrypting user home dir..."))
            encfs.setup(username, self.dest_dir)
            self.queue_event('debug', _("User home dir encrypted"))

        # Install boot loader (always after running mkinitcpio)
        if self.settings.get('install_bootloader'):
github Antergos / Cnchi / src / installation / install.py View on Github external
if os.path.exists('/install/boot/intel-ucode.img'):
            logging.debug("Removing previous intel-ucode.img file found in /boot")
            os.remove('/install/boot/intel-ucode.img')
        if os.path.exists('/install/boot/grub/themes/Antergos-Default'):
            logging.debug("Removing previous Antergos-Default grub2 theme found in /boot")
            shutil.rmtree('/install/boot/grub/themes/Antergos-Default')

        logging.debug("Preparing pacman...")
        self.prepare_pacman()
        logging.debug("Pacman ready")

        # Run driver's pre-install scripts
        try:
            logging.debug("Running hardware drivers pre-install jobs...")
            proprietary = self.settings.get('feature_graphic_drivers')
            self.hardware_install = hardware.HardwareInstall(
                self.settings.get("cnchi"),
                use_proprietary_graphic_drivers=proprietary)
            self.hardware_install.pre_install(DEST_DIR)
        except Exception as ex:
            template = "Error in hardware module. " \
                       "An exception of type {0} occured. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            logging.error(message)

        logging.debug("Downloading packages...")
        self.download_packages()

        # This mounts (binds) /dev and others to /DEST_DIR/dev and others
        special_dirs.mount(DEST_DIR)

        logging.debug("Installing packages...")
github Antergos / Cnchi / cnchi.tmp / cnchi / installation / install.py View on Github external
"/install/boot/initramfs-linux-lts-fallback.img")

        for img in kernel_imgs:
            if os.path.exists(img):
                os.remove(img)

        logging.debug("Preparing pacman...")
        self.prepare_pacman()
        logging.debug("Pacman ready")

        # Run pre-install scripts (only catalyst does something here atm)
        # Note: Catalyst is disabled in catalyst.py
        try:
            logging.debug("Running hardware drivers pre-install jobs...")
            proprietary = self.settings.get('feature_graphic_drivers')
            self.hardware_install = hardware.HardwareInstall(
                use_proprietary_graphic_drivers=proprietary)
            self.hardware_install.pre_install(DEST_DIR)
        except Exception as ex:
            template = "Error in hardware module. An exception of type {0} occured. Arguments:\n{1!r}"
            message = template.format(type(ex).__name__, ex.args)
            logging.error(message)

        logging.debug("Downloading packages...")
        self.download_packages()

        # This mounts (binds) /dev and others to /DEST_DIR/dev and others
        special_dirs.mount(DEST_DIR)

        logging.debug("Installing packages...")
        self.install_packages()