Ejemplo n.º 1
0
    def _add_package_header_values(self, package_ids):
        if not package_ids:
            return
        h = rhnSQL.prepare(self._query_add_package_header_values)
        for package_id, (path, header_start,
                         header_end) in package_ids.items():
            try:
                p_file = file(self.options.prefix + "/" + path, 'r')
            except IOError:
                print("Error opening file %s" % path)
                continue

            try:
                (header_start,
                 header_end) = rhn_rpm.get_header_byte_range(p_file)
            except InvalidPackageError:
                e = sys.exc_info()[1]
                print("Error reading header size from file %s: %s" % (path, e))

            try:
                h.execute(package_id=package_id,
                          header_start=header_start,
                          header_end=header_end)
            except rhnSQL.SQLError:
                pass
Ejemplo n.º 2
0
    def _add_package_header_values(self, package_ids):
        if not package_ids:
            return
        h = rhnSQL.prepare(self._query_add_package_header_values)
        for package_id, (path, header_start, header_end) in package_ids.items():
            try:
                p_file = file(self.options.prefix + "/" + path, 'r')
            except IOError:
                print "Error opening file %s" % path
                continue

            try:
                (header_start, header_end) = rhn_rpm.get_header_byte_range(p_file)
            except InvalidPackageError, e:
                print "Error reading header size from file %s: %s" % (path, e)

            try:
                h.execute(package_id=package_id, header_start=header_start, header_end=header_end)
            except rhnSQL.SQLError, e:
                pass
Ejemplo n.º 3
0
def load_package(package_stream):
    if package_stream.name.endswith(".deb"):
        try:
            header, payload_stream = rhn_deb.load(filename=package_stream.name)
        except:
            raise_with_tb(rhnFault(50, "Unable to load package", explain=0), sys.exc_info()[2])
    else:
        try:
            header, payload_stream = rhn_mpm.load(file=package_stream)
        except:
            raise_with_tb(rhnFault(50, "Unable to load package", explain=0), sys.exc_info()[2])

    payload_stream.seek(0, 0)
    if header.packaging == "mpm" or header.packaging == "deb":
        header.header_start = header.header_end = 0
        (header_start, header_end) = (0, 0)
    else:
        (header_start, header_end) = get_header_byte_range(payload_stream)
        payload_stream.seek(0, 0)

    return header, payload_stream, header_start, header_end
Ejemplo n.º 4
0
def load_package(package_stream):
    if package_stream.name.endswith('.deb'):
        try:
            header, payload_stream = rhn_deb.load(filename=package_stream.name)
        except:
            raise rhnFault(50, "Unable to load package", explain=0), None, sys.exc_info()[2]
    else:
        try:
            header, payload_stream = rhn_mpm.load(file=package_stream)
        except:
            raise rhnFault(50, "Unable to load package", explain=0), None, sys.exc_info()[2]

    payload_stream.seek(0, 0)
    if header.packaging == "mpm" or header.packaging == "deb":
        header.header_start = header.header_end = 0
        (header_start, header_end) = (0, 0)
    else:
        (header_start, header_end) = get_header_byte_range(payload_stream)
        payload_stream.seek(0, 0)

    return header, payload_stream, header_start, header_end