Ejemplo n.º 1
0
 def test_not_existing_location(self):
     rep = Repackage()
     # different versions raise different exception
     if hasattr(urllib2, 'URLError'):
         exc = urllib2.URLError
     else:
         exc = urllib2.HTTPError
     self.assertRaises(exc, rep.download,
             'http://builder.addons.mozilla.org/wrong_file.xpi')
Ejemplo n.º 2
0
 def test_main_dir_files_existence(self):
     rep = Repackage()
     xpi_path = os.path.join(
         self.xpi_file_prefix, 'infocon10sdk11icons.xpi')
     rep.download(xpi_path)
     response = rep.rebuild(self.sdk_source_dir, self.hashtag)
     assert not response[1]
     with open(os.path.join(settings.XPI_TARGETDIR,
                            "%s.xpi" % self.hashtag)) as xpi_file:
         xpi = zipfile.ZipFile(xpi_file)
         filenames = xpi.namelist()
         xpi.close()
     assert 'icon.png' in filenames
     assert 'icon64.png' in filenames
     assert 'icon16.png' in filenames
Ejemplo n.º 3
0
def rebuild_from_location(location,
                          sdk_source_dir,
                          hashtag,
                          package_overrides=None,
                          filename=None,
                          pingback=None,
                          post=None,
                          options=None,
                          **kwargs):
    """creates a Repackage instance, downloads xpi and rebuilds it

    :params:
        * location (String) location of the file to download rebuild ``XPI``
        * sdk_source_dir (String) absolute path of the SDK
        * hashtag (String) filename for the buid XPI
        * package_overrides (dict) override original ``package.json`` fields
        * filename (String) desired filename for the downloaded ``XPI``
        * pingback (String) URL to pass the result
        * post (String) urlified ``request.POST``
        * kwargs is just collecting the task decorator overhead

    :returns: (list) ``cfx xpi`` response where ``[0]`` is ``stdout`` and
              ``[1]`` ``stderr``
    """
    if not package_overrides:
        package_overrides = {}
    rep = Repackage()
    info_path = '%s.json' % os.path.join(settings.XPI_TARGETDIR, hashtag)
    data = {'secret': settings.AMO_SECRET_KEY, 'result': 'failure'}
    log.info("[%s] Starting package rebuild... (%s)" % (hashtag, location))
    try:
        rep.download(location)
    except Exception, err:
        log.debug("[%s] Saving error info to %s" % (hashtag, info_path))
        info_write(info_path, 'error', str(err), hashtag)
        log.warning("[%s] Error in downloading xpi (%s)\n%s" %
                    (hashtag, location, str(err)))
        if pingback:
            data['msg'] = str(err)
            urllib2.urlopen(pingback,
                            data=urllib.urlencode(data),
                            timeout=settings.URLOPEN_TIMEOUT)
        raise
Ejemplo n.º 4
0
 def test_forcing_version(self):
     for sample in self.sample_addons:
         rep = Repackage()
         rep.download(os.path.join(self.xpi_file_prefix, sample))
         rep.get_manifest({'version': 'force.version'})
     eq_(rep.manifest['version'], 'force.version')
Ejemplo n.º 5
0
 def test_repackage(self):
     for sample in self.sample_addons:
         rep = Repackage()
         rep.download(os.path.join(self.xpi_file_prefix, sample))
         response = rep.rebuild(self.sdk_source_dir, self.hashtag)
         assert not response[1]