示例#1
0
    def get(self):
        q = None

        try:
            q = self.get_query_argument('q')
        except tornado.web.MissingArgumentError as mae:
            logging.error(mae)
            self.set_status(http.HTTPStatus.BAD_REQUEST)
            self.write("No query argument 'q' provided")

        if q:
            logging.debug("nevra'ing q=%s" % q)

            subject = dnf.subject.Subject(q)

            results = []

            for nevra_obj in subject.get_nevra_possibilities(
                    forms=[hawkey.FORM_NEVRA]):
                # nevra_obj.name, nevra_obj.epoch, nevra_obj.version, nevra_obj.release, nevra_obj.arch

                result = {}
                result['name'] = nevra_obj.name
                result['version'] = nevra_obj.version
                result['release'] = nevra_obj.release
                result['arch'] = nevra_obj.arch

                results.append(result)

            self.write(json.dumps(results))
def get_NVRA_from_NEVRA(string: str) -> str:
    form = hawkey.FORM_NEVRA

    # get a hawkey.Subject object for the string
    subject = dnf.subject.Subject(string)  # returns hawkey.Subject

    # get a list of hawkey.NEVRA objects that are the possibilities
    nevras = subject.get_nevra_possibilities(forms=form)

    # get a list of hawkey.NEVRA objects that are the possibilities
    nevras = subject.get_nevra_possibilities(forms=form)

    # return the first hawkey.NEVRA item in the list of possibilities
    rpminfo = nevras[0]

    # come up with rpm NVRA
    nvra = f"{rpminfo.name}-{rpminfo.version}-{rpminfo.release}.{rpminfo.arch}"
    return nvra
示例#3
0
 def _read_rpms(self, file_path):
     with open(file_path, "r") as f:
         for line in f:
             subject = dnf.subject.Subject(line.strip())
             nevra_possibilities = subject.get_nevra_possibilities(forms=[hawkey.FORM_NEVRA,
                                                                          hawkey.FORM_NEVR])
             if nevra_possibilities:
                 nevra = nevra_possibilities[0]
                 self._rpms[nevra.name] = "{}-{}".format(nevra.version, nevra.release)
             else:
                 print("Can't get nevra from line {}".format(line), file=sys.stderr)
示例#4
0
def get_rpminfo(string: str) -> str:
    form = hawkey.FORM_NEVRA

    # get a hawkey.Subject object for the string
    subject = dnf.subject.Subject(string)  # returns hawkey.Subject

    # get a list of hawkey.NEVRA objects that are the possibilities
    nevras = subject.get_nevra_possibilities(forms=form)

    # return the first hawkey.NEVRA item in the list of possibilities
    rpminfo = nevras[0]
    return rpminfo
def get_rich_info_for_rpm_string(string: str, arch: bool) -> hawkey.NEVRA:
    # arch: (bool) whether arch is included in the string
    if arch:
        form=hawkey.FORM_NEVRA
    else:
        form=hawkey.FORM_NEVR

    # get a hawkey.Subject object for the string
    subject = dnf.subject.Subject(string) # returns hawkey.Subject

    # get a list of hawkey.NEVRA objects that are the possibilities
    nevras  = subject.get_nevra_possibilities(forms=form)

    # return the first hawkey.NEVRA item in the list of possibilities
    info = nevras[0]
    #   print(info.name)
    #   print(info.version)
    #   print(info.epoch)
    #   print(info.release)
    #   print(info.arch)
    return info