Exemple #1
0
def getArch():
    if os.access("/etc/rpm/platform", os.R_OK):
        fd = open("/etc/rpm/platform", "r")
        platform = fd.read().strip()

        #bz 216225
        #handle some replacements..
        replace = {"ia32e-redhat-linux": "x86_64-redhat-linux"}
        if platform in replace:
            platform = replace[platform]
        return platform
    arch = os.uname()[4]
    if getPlatform() == 'deb':
        # On debian we only support i386
        if arch in ['i486', 'i586', 'i686']:
            arch = 'i386'
        if arch == 'x86_64':
            arch = 'amd64'
        arch += '-debian-linux'
    return arch
Exemple #2
0
def getArch():
    if os.access("/etc/rpm/platform", os.R_OK):
        fd = open("/etc/rpm/platform", "r")
        platform = fd.read().strip()

        # bz 216225
        # handle some replacements..
        replace = {"ia32e-redhat-linux": "x86_64-redhat-linux"}
        if platform in replace:
            platform = replace[platform]
        return platform
    arch = os.uname()[4]
    if getPlatform() == "deb":
        # On debian we only support i386
        if arch in ["i486", "i586", "i686"]:
            arch = "i386"
        if arch == "x86_64":
            arch = "amd64"
        arch += "-debian-linux"
    return arch
Exemple #3
0
"""utility functions for up2date"""

import os
import gettext
from up2date_client import up2dateErrors
from up2date_client import config
from up2date_client.pkgplatform import getPlatform
from rhn.i18n import sstr, bstr

t = gettext.translation('rhn-client-tools', fallback=True)
# Python 3 translations don't have a ugettext method
if not hasattr(t, 'ugettext'):
    t.ugettext = t.gettext
_ = t.ugettext

if getPlatform() == 'deb':
    import lsb_release
    def _getOSVersionAndRelease():
        dist_info = lsb_release.get_distro_information()
        os_name = dist_info['ID']
        os_version = 'n/a'
        if 'CODENAME' in dist_info:
            os_version = dist_info['CODENAME']
        os_release = dist_info['RELEASE']
        return os_name, os_version, os_release

else:
    from up2date_client import transaction
    def _getOSVersionAndRelease():
        osVersionRelease = None
        ts = transaction.initReadOnlyTransaction()
Exemple #4
0
t = gettext.translation('rhn-client-tools', fallback=True)
# Python 3 translations don't have a ugettext method
if not hasattr(t, 'ugettext'):
    t.ugettext = t.gettext
_ = t.ugettext
import OpenSSL
from platform import dist
from rhn.i18n import ustr
from up2date_client import config
from up2date_client import up2dateLog
from up2date_client.pkgplatform import getPlatform

import sys
sys.path = sys.path[1:] + sys.path[:1]

if getPlatform() == 'deb' or dist()[0] == 'SuSE':
    class PmBaseError(Exception):
        def __init__(self, errmsg):
            self.value = errmsg
        def __getattr__(self, name):
            raise AttributeError(_("class %s has no attribute '%s'") % (self.__class__.__name__, name))
        def __setattr__(self, name, value):
            if name in ['errmsg', 'value']:
                self.__dict__['value'] = value
            else:
                self.__dict__[name] = value
else:
    try:
        from yum.Errors import YumBaseError as PmBaseError
    except ImportError:
        from dnf.exceptions import Error as PmBaseError
Exemple #5
0
    regNum = result["registration_number"]
    log.log_debug("Server returned status code %s" % statusCode)
    if statusCode == 0:
        return ActivationResult(ActivationResult.ACTIVATED_NOW, regNum)
    elif statusCode == 1:
        return ActivationResult(ActivationResult.ALREADY_USED, regNum)
    else:
        message = "The server returned unknown status code %s while activating" " the hardware info." % statusCode
        raise up2dateErrors.CommunicationError(message)


def spawnRhnCheckForUI():
    if os.access("/usr/sbin/rhn_check", os.R_OK | os.X_OK):
        from subprocess import Popen, PIPE

        p = Popen(["/usr/sbin/rhn_check"], stdin=PIPE, stdout=PIPE, stderr=PIPE)
        map(lambda x: log.log_me(x), p.stdout.readlines() + p.stderr.readlines())
    else:
        log.log_me("Warning: unable to run rhn_check")


if getPlatform() == "deb":

    def pluginEnable():
        """On Debian no extra action for plugin is needed"""
        return 1, 0


else:
    from up2date_client.pmPlugin import pluginEnable
Exemple #6
0
t = gettext.translation('rhn-client-tools', fallback=True)
# Python 3 translations don't have a ugettext method
if not hasattr(t, 'ugettext'):
    t.ugettext = t.gettext
_ = t.ugettext
import OpenSSL
from platform import dist
from rhn.i18n import ustr
from up2date_client import config
from up2date_client import up2dateLog
from up2date_client.pkgplatform import getPlatform

import sys
sys.path = sys.path[1:] + sys.path[:1]

if getPlatform() == 'deb' or dist()[0] == 'SuSE':

    class PmBaseError(Exception):
        def __init__(self, errmsg):
            self.value = errmsg

        def __getattr__(self, name):
            raise AttributeError(
                _("class %s has no attribute '%s'") %
                (self.__class__.__name__, name))

        def __setattr__(self, name, value):
            if name in ['errmsg', 'value']:
                self.__dict__['value'] = value
            else:
                self.__dict__[name] = value