예제 #1
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
예제 #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
예제 #3
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')
예제 #4
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
예제 #5
0
def rebuild(location, upload, sdk_source_dir, hashtag,
        package_overrides={}, 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``
    """
    rep = Repackage()
    info_path = '%s.json' % os.path.join(settings.XPI_TARGETDIR, hashtag)
    data = {
        'secret': settings.AMO_SECRET_KEY,
        'result': 'failure'}
    if location:
        log.info("[%s] Starting package rebuild... (%s)" % (hashtag, location))
        try:
            rep.download(location)
            log.debug("All fine")
        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
        log.debug("[%s] XPI file downloaded (%s)" % (hashtag, location))
        if not filename:
            filename = '.'.join(
                os.path.basename(urlparse(location).path).split('.')[0:-1])
예제 #6
0
파일: tasks.py 프로젝트: Jnull/FlightDeck
def rebuild_from_upload(upload, 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:
        * upload - uploaded XPI file
        * 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 from upload" % hashtag)
    try:
        rep.retrieve(upload)
    except Exception, err:
        info_write(info_path, 'error', str(err), hashtag)
        log.warning("[%s] Error in retrieving xpi (%s)\n%s" % (hashtag,
            upload, str(err)))
        if pingback:
            data['msg'] = str(err)
            urllib2.urlopen(pingback, data=urllib.urlencode(data),
                    timeout=settings.URLOPEN_TIMEOUT)
        raise
예제 #7
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')
예제 #8
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]
예제 #9
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')
예제 #10
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]