Ejemplo n.º 1
0
    def _dopkgtup(self, hdr):
        tmpepoch = hdr['epoch']
        if tmpepoch is None: epoch = '0'
        else: epoch = str(tmpepoch)

        return (bytes_to_string(hdr['name']), bytes_to_string(hdr['arch']),
                epoch, bytes_to_string(hdr['version']),
                bytes_to_string(hdr['release']))
Ejemplo n.º 2
0
    def buildTransaction(self):
        if not self.Z:
            self.__initialize_zypp()

        if not self.Z.resolver().resolvePool():
            probs = self.Z.resolver().problems()

            for problem in probs:
                description = bytes_to_string(problem.description())
                details = bytes_to_string(problem.details())
                msger.warning("repo problem: {}, {}".format(description, details))

            raise RepoError("found %d resolver problem, abort!" \
                            % len(probs))
Ejemplo n.º 3
0
def query_package_rpmdb(root='/', tag='name', pattern=None):
    name = pattern
    version = None
    ts = rpm.TransactionSet(root)
    mi = ts.dbMatch(tag, pattern)
    for hdr in mi:
        version = bytes_to_string(hdr['version'])
    return (name, version)
Ejemplo n.º 4
0
    def getFilelist(self, pkgname):
        if not pkgname:
            return None

        if not self.ts:
            self.__initialize_transaction()

        mi = self.ts.dbMatch('name', pkgname)
        for header in mi:
            return bytes_to_string(header['FILENAMES'])
Ejemplo n.º 5
0
def _general_print(head, color, msg=None, stream=None, level='normal'):
    global LOG_CONTENT
    if not stream:
        stream = sys.stdout

    if LOG_LEVELS[level] > LOG_LEVEL:
        # skip
        return

    errormsg = ''
    if CATCHERR_BUFFILE_FD > 0:
        size = os.lseek(CATCHERR_BUFFILE_FD, 0, os.SEEK_END)
        os.lseek(CATCHERR_BUFFILE_FD, 0, os.SEEK_SET)
        errormsg = os.read(CATCHERR_BUFFILE_FD, size)
        os.ftruncate(CATCHERR_BUFFILE_FD, 0)

    # append error msg to LOG
    if errormsg:
        errormsg = bytes_to_string(errormsg)
        LOG_CONTENT += errormsg

    msg = bytes_to_string(msg)

    # append normal msg to LOG
    save_msg = msg.strip() if msg else None
    if save_msg:
        global HOST_TIMEZONE
        timestr = time.strftime("[%m/%d %H:%M:%S] ",
                                time.gmtime(time.time() - HOST_TIMEZONE))
        LOG_CONTENT += str(timestr) + save_msg + "\n"
        head += timestr

    if errormsg:
        _color_print('', NO_COLOR, errormsg, stream, level)

    _color_print(head, color, msg, stream, level)