Пример #1
0
    def get(self, **url):
        query = self.getQueryFromURL(url)
        self.log.debug("Got query: %s", query)
        release, update_type = AUS.evaluateRules(query)
        # passing {},None returns empty xml
        if release:
            response_products = release.getResponseProducts()
            response_blobs = []
            if response_products:
                # if we have a SuperBlob, we process the response products and
                # concatenate their inner XMLs
                for product in response_products:
                    product_query = query.copy()
                    product_query["product"] = product
                    response_release, response_update_type = AUS.evaluateRules(product_query)
                    if not response_release:
                        continue

                    response_blobs.append({'product_query': product_query,
                                           'response_release': response_release,
                                           'response_update_type': response_update_type})
            else:
                response_blobs.append({'product_query': query,
                                       'response_release': release,
                                       'response_update_type': update_type})

            xml = ['<?xml version="1.0"?>']
            xml.append('<updates>')

            # We only sample the first blob for the header and footer, since we
            # assume that all blobs will have similar ones. We might want to
            # verify that all of them are indeed the same in the future.

            xml.append(response_blobs[0]['response_release']
                       .getHeaderXML(response_blobs[0]['product_query'],
                                     response_blobs[0]['response_update_type']))
            for response_blob in response_blobs:
                xml.extend(response_blob['response_release']
                           .getInnerXML(response_blob['product_query'],
                                        response_blob['response_update_type'],
                                        app.config["WHITELISTED_DOMAINS"],
                                        app.config["SPECIAL_FORCE_HOSTS"]))
            # Sampling the footer from the first blob
            xml.append(response_blobs[0]['response_release'].getFooterXML())
            xml.append('</updates>')
            # ensure valid xml by using the right entity for ampersand
            xml = re.sub('&(?!amp;)', '&amp;', '\n'.join(xml))
        else:
            xml = ['<?xml version="1.0"?>']
            xml.append('<updates>')
            xml.append('</updates>')
            xml = "\n".join(xml)
        self.log.debug("Sending XML: %s", xml)
        response = make_response(xml)
        response.mimetype = "text/xml"
        return response
Пример #2
0
 def get(self, **url):
     query = self.getQueryFromURL(url)
     self.log.debug("Got query: %s", query)
     release, update_type = AUS.evaluateRules(query)
     # passing {},None returns empty xml
     xml = AUS.createXML(query, release, update_type)
     self.log.debug("Sending XML: %s", xml)
     response = make_response(xml)
     response.mimetype = 'text/xml'
     return response
Пример #3
0
 def get(self, queryVersion, **url):
     query = self.getQueryFromURL(queryVersion, url)
     self.log.debug("Got query: %s", query)
     if query:
         rule = AUS.evaluateRules(query)
     else:
         rule = {}
     # passing {},{} returns empty xml
     self.log.debug("Got rule: %s", rule)
     xml = AUS.createXML(query, rule)
     self.log.debug("Sending XML: %s", xml)
     response = make_response(xml)
     response.mimetype = 'text/xml'
     return response
Пример #4
0
 def get(self, **url):
     query = self.getQueryFromURL(url)
     self.log.debug("Got query: %s", query)
     release, update_type = AUS.evaluateRules(query)
     # passing {},None returns empty xml
     if release:
         xml = release.createXML(query, update_type, app.config["WHITELISTED_DOMAINS"], app.config["SPECIAL_FORCE_HOSTS"])
     else:
         xml = ['<?xml version="1.0"?>']
         xml.append('<updates>')
         xml.append('</updates>')
         xml = "\n".join(xml)
     self.log.debug("Sending XML: %s", xml)
     response = make_response(xml)
     response.mimetype = "text/xml"
     return response
Пример #5
0
 def get(self, **url):
     query = self.getQueryFromURL(url)
     self.log.debug("Got query: %s", query)
     release, update_type = AUS.evaluateRules(query)
     # passing {},None returns empty xml
     if release:
         xml = release.createXML(query, update_type,
                                 app.config["WHITELISTED_DOMAINS"],
                                 app.config["SPECIAL_FORCE_HOSTS"])
     else:
         xml = ['<?xml version="1.0"?>']
         xml.append('<updates>')
         xml.append('</updates>')
         xml = "\n".join(xml)
     self.log.debug("Sending XML: %s", xml)
     response = make_response(xml)
     response.mimetype = "text/xml"
     return response
Пример #6
0
    def get(self, **url):
        query = self.getQueryFromURL(url)
        self.log.debug("Got query: %s", query)
        release, update_type = AUS.evaluateRules(query)

        # passing {},None returns empty xml
        if release:
            response_products = release.getResponseProducts()
            response_blobs = []
            response_blob_names = release.getResponseBlobs()
            if response_products:
                # if we have a SuperBlob of gmp, we process the response products and
                # concatenate their inner XMLs
                for product in response_products:
                    product_query = query.copy()
                    product_query["product"] = product
                    response_release, response_update_type = AUS.evaluateRules(product_query)
                    if not response_release:
                        continue

                    response_blobs.append({'product_query': product_query,
                                           'response_release': response_release,
                                           'response_update_type': response_update_type})
            elif response_blob_names:
                for blob_name in response_blob_names:
                    # if we have a SuperBlob of systemaddons, we process the response products and
                    # concatenate their inner XMLs
                    product_query = query.copy()
                    product = dbo.releases.getReleases(name=blob_name, limit=1)[0]['product']
                    product_query["product"] = product
                    response_release = dbo.releases.getReleaseBlob(name=blob_name)
                    if not response_release:
                        self.log.warning("No release found with name: %s", blob_name)
                        continue

                    response_blobs.append({'product_query': product_query,
                                           'response_release': response_release,
                                           'response_update_type': update_type})
            else:
                response_blobs.append({'product_query': query,
                                       'response_release': release,
                                       'response_update_type': update_type})

            # getHeaderXML() returns outermost header for an update which
            # is same for all release type
            xml = release.getHeaderXML()
            # we assume that all blobs will have similar ones. We might want to
            # verify that all of them are indeed the same in the future.

            # Appending Header
            # In case of superblob Extracting Header form parent release
            xml.append(release.getInnerHeaderXML(query,
                                                 update_type,
                                                 app.config["WHITELISTED_DOMAINS"],
                                                 app.config["SPECIAL_FORCE_HOSTS"]))
            for response_blob in response_blobs:
                xml.extend(response_blob['response_release']
                           .getInnerXML(response_blob['product_query'],
                                        response_blob['response_update_type'],
                                        app.config["WHITELISTED_DOMAINS"],
                                        app.config["SPECIAL_FORCE_HOSTS"]))
            # Appending Footer
            # In case of superblob Extracting Header form parent release
            xml.append(release.getInnerFooterXML(query,
                                                 update_type,
                                                 app.config["WHITELISTED_DOMAINS"],
                                                 app.config["SPECIAL_FORCE_HOSTS"]))
            xml.append(release.getFooterXML())
            # ensure valid xml by using the right entity for ampersand
            xml = re.sub('&(?!amp;)', '&amp;', '\n'.join(xml))
        else:
            xml = ['<?xml version="1.0"?>']
            xml.append('<updates>')
            xml.append('</updates>')
            xml = "\n".join(xml)
        self.log.debug("Sending XML: %s", xml)
        response = make_response(xml)
        response.headers["Cache-Control"] = self.cacheControl
        response.mimetype = "text/xml"
        return response
Пример #7
0
    def get(self, **url):
        query = self.getQueryFromURL(url)
        self.log.debug("Got query: %s", query)
        release, update_type = AUS.evaluateRules(query)
        # passing {},None returns empty xml
        if release:
            response_products = release.getResponseProducts()
            response_blobs = []
            if response_products:
                # if we have a SuperBlob, we process the response products and
                # concatenate their inner XMLs
                for product in response_products:
                    product_query = query.copy()
                    product_query["product"] = product
                    response_release, response_update_type = AUS.evaluateRules(
                        product_query)
                    if not response_release:
                        continue

                    response_blobs.append({
                        'product_query':
                        product_query,
                        'response_release':
                        response_release,
                        'response_update_type':
                        response_update_type
                    })
            else:
                response_blobs.append({
                    'product_query': query,
                    'response_release': release,
                    'response_update_type': update_type
                })

            xml = ['<?xml version="1.0"?>']
            xml.append('<updates>')

            # We only sample the first blob for the header and footer, since we
            # assume that all blobs will have similar ones. We might want to
            # verify that all of them are indeed the same in the future.

            xml.append(response_blobs[0]['response_release'].getHeaderXML(
                response_blobs[0]['product_query'],
                response_blobs[0]['response_update_type']))
            for response_blob in response_blobs:
                xml.extend(response_blob['response_release'].getInnerXML(
                    response_blob['product_query'],
                    response_blob['response_update_type'],
                    app.config["WHITELISTED_DOMAINS"],
                    app.config["SPECIAL_FORCE_HOSTS"]))
            # Sampling the footer from the first blob
            xml.append(response_blobs[0]['response_release'].getFooterXML())
            xml.append('</updates>')
            # ensure valid xml by using the right entity for ampersand
            xml = re.sub('&(?!amp;)', '&amp;', '\n'.join(xml))
        else:
            xml = ['<?xml version="1.0"?>']
            xml.append('<updates>')
            xml.append('</updates>')
            xml = "\n".join(xml)
        self.log.debug("Sending XML: %s", xml)
        response = make_response(xml)
        response.mimetype = "text/xml"
        return response
Пример #8
0
    def get(self, **url):
        query = self.getQueryFromURL(url)
        self.log.debug("Got query: %s", query)
        release, update_type = AUS.evaluateRules(query)

        # passing {},None returns empty xml
        if release:
            response_products = release.getResponseProducts()
            response_blobs = []
            response_blob_names = release.getResponseBlobs()
            if response_products:
                # if we have a SuperBlob of gmp, we process the response products and
                # concatenate their inner XMLs
                for product in response_products:
                    product_query = query.copy()
                    product_query["product"] = product
                    response_release, response_update_type = AUS.evaluateRules(
                        product_query)
                    if not response_release:
                        continue

                    response_blobs.append({
                        'product_query':
                        product_query,
                        'response_release':
                        response_release,
                        'response_update_type':
                        response_update_type
                    })
            elif response_blob_names:
                for blob_name in response_blob_names:
                    # if we have a SuperBlob of systemaddons, we process the response products and
                    # concatenate their inner XMLs
                    product_query = query.copy()
                    product = dbo.releases.getReleases(name=blob_name,
                                                       limit=1)[0]['product']
                    product_query["product"] = product
                    response_release = dbo.releases.getReleaseBlob(
                        name=blob_name)
                    if not response_release:
                        self.log.warning("No release found with name: %s",
                                         blob_name)
                        continue

                    response_blobs.append({
                        'product_query': product_query,
                        'response_release': response_release,
                        'response_update_type': update_type
                    })
            else:
                response_blobs.append({
                    'product_query': query,
                    'response_release': release,
                    'response_update_type': update_type
                })

            # getHeaderXML() returns outermost header for an update which
            # is same for all release type
            xml = release.getHeaderXML()
            # we assume that all blobs will have similar ones. We might want to
            # verify that all of them are indeed the same in the future.

            # Appending Header
            # In case of superblob Extracting Header form parent release
            xml.append(
                release.getInnerHeaderXML(query, update_type,
                                          app.config["WHITELISTED_DOMAINS"],
                                          app.config["SPECIAL_FORCE_HOSTS"]))
            for response_blob in response_blobs:
                xml.extend(response_blob['response_release'].getInnerXML(
                    response_blob['product_query'],
                    response_blob['response_update_type'],
                    app.config["WHITELISTED_DOMAINS"],
                    app.config["SPECIAL_FORCE_HOSTS"]))
            # Appending Footer
            # In case of superblob Extracting Header form parent release
            xml.append(
                release.getInnerFooterXML(query, update_type,
                                          app.config["WHITELISTED_DOMAINS"],
                                          app.config["SPECIAL_FORCE_HOSTS"]))
            xml.append(release.getFooterXML())
            # ensure valid xml by using the right entity for ampersand
            xml = re.sub('&(?!amp;)', '&amp;', '\n'.join(xml))
        else:
            xml = ['<?xml version="1.0"?>']
            xml.append('<updates>')
            xml.append('</updates>')
            xml = "\n".join(xml)
        self.log.debug("Sending XML: %s", xml)
        response = make_response(xml)
        response.headers["Cache-Control"] = self.cacheControl
        response.mimetype = "text/xml"
        return response