Пример #1
0
 def __init__(self):
     PackagerBase.__init__(self)
     self.command = None
     if sysutils.which('dnf') is not None:
         self.command = 'dnf'
     elif sysutils.which('yum') is not None:
         self.command = 'yum'
Пример #2
0
 def __init__(self):
     PackagerBase.__init__(self)
     self.command = None
     if sysutils.which("dnf") is not None:
         self.command = "dnf"
     elif sysutils.which("yum") is not None:
         self.command = "yum"
Пример #3
0
 def __init__(self):
     PackagerBase.__init__(self)
     self.command = None
     if sysutils.which('dnf') is not None:
         self.command = 'dnf'
     elif sysutils.which('yum') is not None:
         self.command = 'yum'
Пример #4
0
 def __init__(self, logger):
     ExternPackager.__init__(self, logger)
     self.command = None
     if sysutils.which('dnf') is not None:
         self.command = 'dnf'
     elif sysutils.which('yum') is not None:
         self.command = 'yum'
Пример #5
0
 def __init__(self, logger):
     ExternPackager.__init__(self, logger)
     self.command = None
     if sysutils.which('dnf') is not None:
         self.command = 'dnf'
     elif sysutils.which('yum') is not None:
         self.command = 'yum'
Пример #6
0
 def _auto_config_elevate_pre_args(self):
     " Automatically set: elevate_pre_args "
     from pybombs.utils import sysutils
     if sysutils.which('sudo'):
         return ['sudo', '-H']
     if sysutils.which('pkexec'):
         return ['pkexec']
     return ''
Пример #7
0
 def _auto_config_elevate_pre_args(self):
     " Automatically set: elevate_pre_args "
     from pybombs.utils import sysutils
     if sysutils.which('sudo'):
         return ['sudo', '-H']
     if sysutils.which('pkexec'):
         return ['pkexec']
     return ''
Пример #8
0
 def supported(self):
     """
     Check if we can even run apt-get.
     Return True if so.
     """
     return sysutils.which('dpkg') is not None \
         and sysutils.which('apt-cache') is not None \
         and sysutils.which('apt-get') is not None
Пример #9
0
 def supported(self):
     """
     Check if we can even run apt-get.
     Return True if so.
     """
     return sysutils.which('dpkg') is not None \
         and sysutils.which('apt-cache') is not None \
         and sysutils.which('apt-get') is not None
Пример #10
0
 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
Пример #11
0
 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
Пример #12
0
 def supported(self):
     """
     Check if we're on a Debian/Ubuntu.
     Return True if so.
     """
     has_dpkg = sysutils.which('dpkg') is not None
     has_apt = sysutils.which('apt') is not None or \
         (sysutils.which('apt-cache') is not None \
         and sysutils.which('apt-get') is not None)
     return has_dpkg and has_apt
Пример #13
0
 def supported(self):
     """
     Check if we're on a Debian/Ubuntu.
     Return True if so.
     """
     has_dpkg = sysutils.which('dpkg') is not None
     has_apt = sysutils.which('apt') is not None or \
         (sysutils.which('apt-cache') is not None \
         and sysutils.which('apt-get') is not None)
     return has_dpkg and has_apt
Пример #14
0
 def supported(self):
     """
     Check if we're on a Debian/Ubuntu.
     Return True if so.
     """
     has_dpkg = sysutils.which('dpkg') is not None
     # has_apt = sysutils.which('apt') is not None or \
     # Replace this line with the one above to re-enable apt (also need to change something above):
     has_apt = False or \
         (sysutils.which('apt-cache') is not None \
         and sysutils.which('apt-get') is not None)
     return has_dpkg and has_apt
Пример #15
0
 def supported(self):
     """
     Check if we're on a Debian/Ubuntu.
     Return True if so.
     """
     has_dpkg = sysutils.which('dpkg') is not None
     # has_apt = sysutils.which('apt') is not None or \
     # Replace this line with the one above to re-enable apt (also need to change something above):
     has_apt = False or \
         (sysutils.which('apt-cache') is not None \
         and sysutils.which('apt-get') is not None)
     return has_dpkg and has_apt
Пример #16
0
def detect_pip_exe():
    """TODO: Docstring for detect_pip_exe.
    :returns: TODO

    """
    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
Пример #17
0
def detect_pip_exe():
    """
    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
Пример #18
0
 def _package_install(self,
                      pkgname,
                      comparator=">=",
                      required_version=None,
                      update=False):
     """
     Call 'pip install pkgname' if we can satisfy the version requirements.
     """
     try:
         self.log.debug("Calling `pip install {pkg}'".format(pkg=pkgname))
         command = [sysutils.which('pip'), "install"]
         if update:
             command.append('--upgrade')
         command.append(pkgname)
         subproc.monitor_process(command, elevate=True)
         self.load_install_cache()
         installed_version = PIP_INSTALLED_CACHE.get(pkgname)
         self.log.debug("Installed version for {pkg} is: {ver}.".format(
             pkg=pkgname, ver=installed_version))
         if installed_version is None:
             return False
         if required_version is None:
             return True
         print required_version, comparator, installed_version
         return vcompare(comparator, installed_version, required_version)
     except Exception as e:
         self.log.error("Running pip install failed.")
         self.log.error(str(e))
     return False
Пример #19
0
 def _run_pip_install(self, pkgname, update=False):
     """
     Run pip install [--upgrade]
     """
     try:
         command = [sysutils.which('pip'), "install"]
         if update:
             command.append('--upgrade')
         command.append(pkgname)
         self.log.debug("Calling `{cmd}'".format(cmd=" ".join(command)))
         subproc.monitor_process(command, elevate=True)
         self.load_install_cache()
         return True
     except Exception as e:
         self.log.error("Running pip install failed.")
         self.log.debug(str(e))
     return None
Пример #20
0
 def _run_pip_install(self, pkgname, update=False):
     """
     Run pip install [--upgrade]
     """
     try:
         command = [sysutils.which('pip'), "install"]
         if update:
             command.append('--upgrade')
         command.append(pkgname)
         self.log.debug("Calling `{cmd}'".format(cmd=" ".join(command)))
         subproc.monitor_process(command, elevate=True)
         self.load_install_cache()
         return True
     except Exception as e:
         self.log.error("Running pip install failed.")
         self.log.debug(str(e))
     return None
Пример #21
0
def _download_with_wget(url):
    " Use the wget tool itself "
    def get_md5(filename):
        " Return MD5 sum of filename using the md5sum tool "
        md5_exe = sysutils.which('md5sum')
        if md5_exe is not None:
            return subproc.check_output([md5_exe, filename])[0:32]
        return None
    from pybombs.utils import sysutils
    from pybombs.utils import subproc
    wget = sysutils.which('wget')
    if wget is None:
        raise PBException("wget executable not found")
    filename = os.path.split(url)[1]
    retval = subproc.monitor_process([wget, url], throw=True)
    if retval:
        raise PBException("wget failed to wget")
    return filename, get_md5(filename)
Пример #22
0
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)
        if sysutils.which('apt') is not None:
            self.getcmd = 'apt'
            self.searchcmd = 'apt'
        else:
            self.getcmd = 'apt'
            self.searchcmd = 'apt-cache'

        try:
            import apt
            self.cache = apt.Cache()
        except (ImportError, AttributeError):
            # ImportError is caused by apt being completely missing
            # AttributeError is caused by us importing ourselves (we have no
            #   Cache() method) because python-apt is missing and we got a
            #   relative import instead
            self.log.info("Install python-apt to speed up apt processing.")
            self.cache = None
Пример #23
0
    def __init__(self, logger):
        ExternPackager.__init__(self, logger)
        if sysutils.which('apt') is not None:
            self.getcmd = 'apt'
            self.searchcmd = 'apt'
        else:
            self.getcmd = 'apt'
            self.searchcmd = 'apt-cache'

        try:
            import apt
            self.cache = apt.Cache()
        except (ImportError, AttributeError):
            # ImportError is caused by apt being completely missing
            # AttributeError is caused by us importing ourselves (we have no
            #   Cache() method) because python-apt is missing and we got a
            #   relative import instead
            self.log.info("Install python-apt to speed up apt processing.")
            self.cache = None
Пример #24
0
    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()
        except (ImportError, AttributeError):
            # ImportError is caused by apt being completely missing
            # AttributeError is caused by us importing ourselves (we have no
            #   Cache() method) because python-apt is missing and we got a
            #   relative import instead
            self.log.info("Install python-apt to speed up apt processing.")
            self.cache = None
Пример #25
0
def _download_with_wget(url):
    " Use the wget tool itself "

    def get_md5(filename):
        " Return MD5 sum of filename using the md5sum tool "
        md5_exe = sysutils.which('md5sum')
        if md5_exe is not None:
            return subproc.check_output([md5_exe, filename])[0:32]
        return None

    from pybombs.utils import sysutils
    from pybombs.utils import subproc
    wget = sysutils.which('wget')
    if wget is None:
        raise PBException("wget executable not found")
    filename = os.path.split(url)[1]
    retval = subproc.monitor_process([wget, url], throw=True)
    if retval:
        raise PBException("wget failed to wget")
    return filename, get_md5(filename)
Пример #26
0
 def supported(self):
     """
     Check if macports is installed
     """
     return sysutils.which('port') is not None
Пример #27
0
 def __init__(self, logger):
     ExternPackager.__init__(self, logger)
     self.command = None
     if sysutils.which('pacman') is not None:
         self.command = 'pacman'
Пример #28
0
 def supported(self):
     """
     Check if we can even run 'pip'.
     Return True if so.
     """
     return sysutils.which('pip') is not None
Пример #29
0
 def supported(self):
     """
     Check if we can even run 'pkg-config'. Return True if yes.
     """
     return sysutils.which('pkg-config') is not None
Пример #30
0
 def supported(self):
     """
     Check if homebrew exists
     Return True if so.
     """
     return sysutils.which('brew') is not None
Пример #31
0
 def supported(self):
     """
     Check if we can even run 'pkg-config'. Return True if yes.
     """
     return sysutils.which('pkg-config') is not None
Пример #32
0
 def supported(self):
     """
     Check if we can even run 'pip'.
     Return True if so.
     """
     return sysutils.which('pip') is not None
Пример #33
0
 def supported(self):
     """
     Check if macports is installed
     """
     return sysutils.which('port') is not None
Пример #34
0
 def supported(self):
     """
     Check if homebrew exists
     Return True if so.
     """
     return sysutils.which('brew') is not None
Пример #35
0
 def __init__(self, logger):
     ExternPackager.__init__(self, logger)
     self.command = None
     if sysutils.which('pacman') is not None:
         self.command = 'pacman'