How to use the pybombs.packagers.extern.ExternPackager function in PyBOMBS

To help you get started, we’ve selected a few PyBOMBS 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 gnuradio / pybombs / pybombs / packagers / pip.py View on Github external
"""
    Returns the path to the pip version used. Factors in the available Python
    version.
    """
    from pybombs.config_manager import config_manager
    if vcompare('>=', config_manager.get_python_version(), '3'):
        default_pip = 'pip3'
    else:
        default_pip = 'pip2'
    if sysutils.which(default_pip) is not None:
        return default_pip
    if sysutils.which('pip') is not None:
        return 'pip'
    return None

class ExternalPip(ExternPackager):
    """
    Wrapper for pip
    """
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)
        self.cmd = detect_pip_exe()
        if self.cmd:
            self.log.debug("Using pip executable: %s", self.cmd)
        else:
            self.log.debug(" pip executable not found.")

    def get_available_version(self, pkgname):
        """
        See if 'pip search' finds our package.
        """
        try:
github gnuradio / pybombs / pybombs / packagers / zypper.py View on Github external
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
"""
Packager: zypper (OpenSUSE)
"""

import os
import re
import subprocess
from pybombs.packagers.extern import ExternCmdPackagerBase, ExternPackager
from pybombs.utils import subproc
from pybombs.utils import sysutils
from pybombs.utils import utils

class ExternalZypper(ExternPackager):
    """
    Wrapper for zypper
    """
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)
        self.command = None
        if sysutils.which('zypper') is not None:
            self.command = 'zypper'
        if sysutils.which('rpm') is not None:
            self.fastcommand = 'rpm'
        else:
            self.fastcommand = None

    def get_available_version(self, pkgname):
        """
        Return a version that we can install through this package manager.
github gnuradio / pybombs / pybombs / packagers / portage.py View on Github external
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyBOMBS; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
"""
Packager: portage
"""

from pybombs.packagers.extern import ExternCmdPackagerBase, ExternPackager
from pybombs.utils import subproc
from pybombs.utils import sysutils

class ExternalPortage(ExternPackager):
    """
    Wrapper for portage
    """
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)
        self.available = False
        try:
            from _emerge import search
            from _emerge import actions
            from _emerge.actions import load_emerge_config
            self.portage = __import__('portage')
            self.re = __import__('re')
            emerge_config = load_emerge_config()
            self.root_config = emerge_config.running_config
            # search init args:
            # (self,root_config,spinner,searchdesc,verbose,usepkg,usepkgconly,search_index=True)
github gnuradio / pybombs / pybombs / packagers / extern.py View on Github external
raise NotImplementedError

    def install(self, pkgname):
        """
        Install pkgname using this packager.
        """
        raise NotImplementedError

    def update(self, pkgname):
        """
        Update pkgname using this packager.
        Defaults to calling install().
        """
        return self.install(pkgname)

class ExternReadOnlyPackager(ExternPackager):
    """
    Wraps a read-only packager, i.e. one that can't itself install packages
    but can find out what's installed.
    """
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)

    def get_available_version(self, pkgname):
        """
        The only available version is the installed version.
        """
        return self.get_installed_version(pkgname)

    def install(self, pkgname):
        """
        Can't install, by definition.
github gnuradio / pybombs / pybombs / packagers / port.py View on Github external
# You should have received a copy of the GNU General Public License
# along with PyBOMBS; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
"""
Packager: port
"""

import re
import subprocess
from pybombs.packagers.extern import ExternCmdPackagerBase, ExternPackager
from pybombs.utils import subproc
from pybombs.utils import sysutils

class ExternalPort(ExternPackager):
    """
    Wrapper around port
    """
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)

    def get_available_version(self, pkgname):
        """
        Search for package with 'port search'
        """
        try:
            out = subproc.check_output(["port", "search", "--name", "--glob", pkgname]).strip()
            if "No match" in out:
                return False
            ver = re.search(r'@(?P[0-9,.]*)', str(out)).group('ver')
            return ver
github gnuradio / pybombs / pybombs / packagers / brew.py View on Github external
# You should have received a copy of the GNU General Public License
# along with PyBOMBS; see the file COPYING.  If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
"""
Packager: homebrew
"""

import json
from pybombs.packagers.extern import ExternCmdPackagerBase, ExternPackager
from pybombs.utils import subproc
from pybombs.utils import sysutils


class ExternalHomebrew(ExternPackager):
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)

    def get_available_version(self, pkgname):
        """
        Check which version is currently installed.
        """
        try:
            self.log.trace("Checking homebrew for `{0}'".format(pkgname))
            out = subproc.check_output(["brew", "info", "--json=v1", pkgname])
            # Returns non-zero exit status if package does not exist in brew taps
            if len(out) >= 0:
                # Get the version.
                pkgdata = json.loads(out)[0]  # Wrapped in a list. get the first element.
                version = pkgdata["versions"]["stable"]
                return version
github gnuradio / pybombs / pybombs / packagers / apt.py View on Github external
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
"""
Packager: apt
"""

from __future__ import absolute_import
import re
import subprocess
from pybombs.packagers.extern import ExternCmdPackagerBase, ExternPackager
from pybombs.utils import subproc
from pybombs.utils import sysutils


class ExternalApt(ExternPackager):
    """
    Wrapper around apt(-get) and dpkg
    """
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)
        # if sysutils.which('apt') is not None:
        if False: # To re-enable apt, replace this line with the one above (also need to change something further down)
            self.getcmd = 'apt'
            self.searchcmd = 'apt'
        else:
            self.getcmd = 'apt-get'
            self.searchcmd = 'apt-cache'

        try:
            import apt
            self.cache = apt.Cache()