Install custom SELinux module from file

    CLI Example:

    .. code-block:: bash

        salt '*' selinux.install_semod [salt://]path/to/module.pp

    .. versionadded:: 2016.11.6
768327
def install_semod(module_path):
    '''
    
    '''
    if module_path.find('salt://') == 0:
        module_path = __salt__['cp.cache_file'](module_path)
    cmd = 'semodule -i {0}'.format(module_path)
    return not __salt__['cmd.retcode'](cmd)
682778
def install_from_pypi(context):
    """"""

    tmp_dir = venv.create_venv()
    install_cmd = '%s/bin/pip install %s' % (tmp_dir, context.module_name)

    package_index = 'pypi'
    if context.pypi:
        install_cmd += '-i %s' % context.pypi
        package_index = context.pypi

    try:
        result = shell.dry_run(install_cmd, context.dry_run)
        if not context.dry_run and not result:
            log.error(
                'Failed to install %s from %s', context.module_name, package_index
            )
        else:
            log.info(
                'Successfully installed %s from %s', context.module_name, package_index
            )

    except Exception as e:
        error_msg = 'Error installing %s from %s' % (context.module_name, package_index)
        log.exception(error_msg)
        raise Exception(error_msg, e)
560011
def importfile(filename):
    
    pkg = packageFromPath(filename, includeModule=True)
    root = packageRootPath(filename)

    if root not in sys.path:
        sys.path.insert(0, root)

    __import__(pkg)
    return sys.modules[pkg]
249672
def upload_module(self, local_path=None, remote_path="/tmp/lime.ko"):
        
        if local_path is None:
            raise FileNotFoundFoundError(local_path)
        self.shell.upload_file(local_path, remote_path)
1220205
def install(editable):
    """"""
    script_dir = str(Path(__file__).parent.abspath())
    click.secho(script_dir, fg='blue')
    if editable:
        sh('pip3 install --editable {0} --upgrade'.format(script_dir))
    else:
        sh('pip3 install {0} --upgrade'.format(script_dir))
780845
def install_hook(self, hook_name, hook_content):
        
        hook_path = os.path.join(self.path, '.git/hooks', hook_name)
        with open(hook_path, 'w') as f:
            f.write(hook_content)
        os.chmod(hook_path, stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
739641
def install(path, remove=False, prefix=sys.prefix, recursing=False):
    
    # this sys.prefix is intentional.  We want to reflect the state of the root installation.
    if sys.platform == 'win32' and not exists(join(sys.prefix, '.nonadmin')):
        if isUserAdmin():
            _install(path, remove, prefix, mode='system')
        else:
            from pywintypes import error
            try:
                if not recursing:
                    retcode = runAsAdmin([join(sys.prefix, 'python'), '-c',
                                          "import menuinst; menuinst.install(%r, %r, %r, %r)" % (
                                              path, bool(remove), prefix, True)])
                else:
                    retcode = 1
            except error:
                retcode = 1

            if retcode != 0:
                logging.warn("Insufficient permissions to write menu folder.  "
                             "Falling back to user location")
                _install(path, remove, prefix, mode='user')
    else:
        _install(path, remove, prefix, mode='user')
519545
def _install(_):
    
    if not os.path.exists(".git"):
        fatal("not in a git repo.")

    config = __load_config()

    if config.get("checks") is None:
        fatal("global ``checks`` variable missing from configuration.")

    # We try to load all checks to check that they exist NOW.
    for hook in config["checks"]:
        checks = __load_checks(config["checks"][hook])
        # Also verify that they apply to the hooks.
        __verify_checks_for_hook(checks, hook)

    reply = input("This will overwrite your current hooks. "
                  "Proceed [yes/No]? ")
    if reply != "yes":
        raise Exit(0)

    for hook in config["checks"]:
        hook_f = open(os.path.join(".git/hooks/", hook), 'w')
        hook_f.write("""#!/usr/bin/env python
# GENRATED BY GLERBL. DO NOT MODIFY.
from glerbl.__main__ import main


exit(main(["glerbl", "hook", "{0}"]))
""".format(hook))
        os.fchmod(hook_f.fileno(),
                  os.fstat(hook_f.fileno()).st_mode | stat.S_IXUSR)
        hook_f.close()
1194533
def run_module(mod_name, init_globals=None,
               run_name=None, alter_sys=False):
    
    mod_name, loader, code, fname = _get_module_details(mod_name)
    if run_name is None:
        run_name = mod_name
    pkg_name = mod_name.rpartition('.')[0]
    if alter_sys:
        return _run_module_code(code, init_globals, run_name,
                                fname, loader, pkg_name)
    else:
        # Leave the sys module alone
        return _run_code(code, {}, init_globals, run_name,
                         fname, loader, pkg_name)
473494
def install_cmd(argv):
    ''''''
    installer = InstallCommand()
    options, versions = installer.parser.parse_args(argv)
    if len(versions) != 1:
        installer.parser.print_help()
        sys.exit(1)
    else:
        try:
            actual_installer = PythonInstaller.get_installer(versions[0], options)
            return actual_installer.install()
        except AlreadyInstalledError as e:
            print(e)
403848
def load(mod, persist=False):
    '''
    
    '''
    pre_mods = lsmod()
    res = __salt__['cmd.run_all']('modprobe {0}'.format(mod), python_shell=False)
    if res['retcode'] == 0:
        post_mods = lsmod()
        mods = _new_mods(pre_mods, post_mods)
        persist_mods = set()
        if persist:
            persist_mods = _set_persistent_module(mod)
        return sorted(list(mods | persist_mods))
    else:
        return 'Error loading module {0}: {1}'.format(mod, res['stderr'])
943405
public static function install()
    {
        static::updatePackages();
        static::updateBootstrapping();

        tap(new Filesystem, function ($filesystem) {
            $filesystem->deleteDirectory(resource_path('js/components'));
            $filesystem->delete(resource_path('sass/_variables.scss'));
            $filesystem->deleteDirectory(base_path('node_modules'));
            $filesystem->deleteDirectory(public_path('css'));
            $filesystem->deleteDirectory(public_path('js'));
        });
    }
631603
function installUdevRules() {
	if (!systemSupportsUdev()) {
		return when.reject(new Error('Not supported'));
	}
	return when.promise((resolve, reject) => {
		const cmd = `sudo cp "${UDEV_RULES_ASSET_FILE}" "${UDEV_RULES_SYSTEM_FILE}"`;
		console.log(cmd);
		childProcess.exec(cmd, err => {
			if (err) {
				_udevRulesInstalled = undefined;
				return reject(new VError(err, 'Could not install udev rules'));
			}
			_udevRulesInstalled = true;
			resolve();
		});
	});
}
1115170
def get_selinux_context(path):
    '''
    
    '''
    out = __salt__['cmd.run'](['ls', '-Z', path], python_shell=False)

    try:
        ret = re.search(r'\w+:\w+:\w+:\w+', out).group(0)
    except AttributeError:
        ret = (
            'No selinux context information is available for {0}'.format(path)
        )

    return ret
1259557
def load_module(self, name):
        """"""
        if name in sys.modules:
            return sys.modules[name]
        # load the actual import hook module
        module_name = self.mount2name(name)
        __import__(module_name)
        # alias the import hook module to the mount, so both can be used interchangeably
        module = sys.modules[name] = sys.modules[module_name]
        module.install()
        return module
917329
def install(self, to, chmod=0644):
        
        self.copy(to)
        path(to).chmod(chmod)
938549
def __setup_fileserver(self):
        '''
        
        '''
        fs_ = salt.fileserver.Fileserver(self.opts)
        self._serve_file = fs_.serve_file
        self._file_find = fs_._find_file
        self._file_hash = fs_.file_hash
        self._file_list = fs_.file_list
        self._file_list_emptydirs = fs_.file_list_emptydirs
        self._dir_list = fs_.dir_list
        self._symlink_list = fs_.symlink_list
        self._file_envs = fs_.envs