예제 #1
0
파일: models.py 프로젝트: atsay/zamboni
    def inject_ids(self):
        """
        For packaged webapps, adds a META-INF/ids.json file with a JSON
        document like the following:
            {"app_id": "6106d3b3-881a-4ddf-9dec-6b2bf8ff8341",
             "version_id": 42}
        """
        app = self.version.addon
        if not (app.type == amo.ADDON_WEBAPP and app.is_packaged):
            return

        filename = 'META-INF/ids.json'
        ids = {
            'app_id': app.guid,
            'version_id': self.version_id,
        }
        zf = SafeUnzip(self.file_path, mode='a')
        zf.is_valid()

        # Check if there's already a META-INF/ids.json.
        try:
            zf.zip.getinfo(filename)
            zf.close()
            return
        except KeyError:
            pass  # Not found, we need to add it.

        zf.zip.writestr(filename, json.dumps(ids))
        zf.close()
예제 #2
0
파일: models.py 프로젝트: flyun/zamboni
    def inject_ids(self):
        """
        For packaged webapps, adds a META-INF/ids.json file with a JSON
        document like the following:
            {"app_id": "6106d3b3-881a-4ddf-9dec-6b2bf8ff8341",
             "version_id": 42}
        """
        app = self.version.addon
        if not (app.type == amo.ADDON_WEBAPP and app.is_packaged):
            return

        filename = 'META-INF/ids.json'
        ids = {
            'app_id': app.guid,
            'version_id': self.version_id,
        }
        zf = SafeUnzip(self.file_path, mode='a')
        zf.is_valid()

        # Check if there's already a META-INF/ids.json.
        try:
            zf.zip.getinfo(filename)
            zf.close()
            return
        except KeyError:
            pass  # Not found, we need to add it.

        zf.zip.writestr(filename, json.dumps(ids))
        zf.close()
예제 #3
0
    def write_watermarked_addon(self, dest, data):
        """
        Writes the watermarked addon to the destination given
        the addons install.rdf data.
        """
        directory = os.path.dirname(dest)
        if not os.path.exists(directory):
            os.makedirs(directory)

        shutil.copyfile(self.file_path, dest)
        outzip = SafeUnzip(dest, mode='a')
        outzip.is_valid()
        outzip.zip.writestr('install.rdf', str(data))
        outzip.close()
예제 #4
0
    def write_watermarked_addon(self, dest, data):
        """
        Writes the watermarked addon to the destination given
        the addons install.rdf data.
        """
        directory = os.path.dirname(dest)
        if not os.path.exists(directory):
            os.makedirs(directory)

        shutil.copyfile(self.file_path, dest)
        outzip = SafeUnzip(dest, mode='a')
        outzip.is_valid()
        outzip.zip.writestr('install.rdf', str(data))
        outzip.close()
예제 #5
0
    def inject_ids(self):
        """
        For packaged webapps, adds a META-INF/ids.json file with a JSON
        document like the following:
            {"id": "6106d3b3-881a-4ddf-9dec-6b2bf8ff8341",
             "version": 42}
        """
        app = self.version.addon
        if not (app.type == amo.ADDON_WEBAPP and app.is_packaged):
            return

        filename = 'META-INF/ids.json'
        ids = {
            'id': app.guid,
            'version': self.version_id,
        }
        zf = SafeUnzip(self.file_path, mode='a')
        zf.is_valid()

        zf.zip.writestr(filename, json.dumps(ids))
        zf.close()