Ejemplo n.º 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 replace.has_key(platform):
            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
Ejemplo n.º 2
0
def getArch():
    if os.access("/etc/rpm/platform", os.R_OK):
        fd = open("/etc/rpm/platform", "r")
        platform = string.strip(fd.read())

        #bz 216225
        #handle some replacements..
        replace = {"ia32e-redhat-linux": "x86_64-redhat-linux"}
        if replace.has_key(platform):
            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
Ejemplo n.º 3
0
# Copyright (c) 1999--2012 Red Hat, Inc.  Distributed under GPLv2.
#
# Author: Preston Brown <*****@*****.**>
#         Adrian Likins <*****@*****.**>
#
"""utility functions for up2date"""

import os
import up2dateErrors
import config
import gettext
from pkgplatform import getPlatform
t = gettext.translation('rhn-client-tools', fallback=True)
_ = 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:
    import transaction
    def _getOSVersionAndRelease():
        ts = transaction.initReadOnlyTransaction()
        for h in ts.dbMatch('Providename', "redhat-release"):
Ejemplo n.º 4
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 yumPlugin import pluginEnable
Ejemplo n.º 5
0
# file(s) with this exception, you may extend this exception to your
# version of the file(s), but you are not obligated to do so.  If you
# do not wish to do so, delete this exception statement from your
# version.  If you delete this exception statement from all source
# files in the program, then also delete it here.

import up2dateLog
import gettext
t = gettext.translation('rhn-client-tools', fallback=True)
_ = t.ugettext
import OpenSSL
import config
from pkgplatform import getPlatform
from platform import dist

if getPlatform() == 'deb' or dist()[0] == 'SuSE':
    class YumBaseError(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:
    from yum.Errors import YumBaseError

class Error(YumBaseError):
    """base class for errors"""
Ejemplo n.º 6
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 yumPlugin import pluginEnable