Пример #1
0
def packager(data, feature_set, **kw):
    """Build an add-on based on input data."""
    log.info("[1@None] Packaging add-on")

    from devhub.views import packager_path

    dest = packager_path(data["slug"])

    with guard(u"devhub.packager.%s" % dest) as locked:
        if locked:
            log.error(u"Packaging in progress: %s" % dest)
            return

        with statsd.timer("devhub.packager"):
            from packager.main import packager

            log.info("Starting packaging: %s" % dest)
            features = set([k for k, v in feature_set.items() if v])
            try:
                packager(data, dest, features)
            except Exception, err:
                log.error(u"Failed to package add-on: %s" % err)
                raise
            if os.path.exists(dest):
                log.info(u"Package saved: %s" % dest)
Пример #2
0
def packager(data, feature_set, **kw):
    """Build an add-on based on input data."""
    log.info('[1@None] Packaging add-on')

    # "Lock" the file by putting .lock in its name.
    from devhub.views import packager_path
    xpi_path = packager_path('%s.lock' % data['uuid'])
    log.info('Saving package to: %s' % xpi_path)

    from packager.main import packager
    features = set([k for k, v in feature_set.items() if v])
    packager(data, xpi_path, features)

    # Unlock the file and make it available.
    try:
        shutil.move(xpi_path, packager_path(data['uuid']))
    except IOError:
        log.error('Error unlocking add-on: %s' % xpi_path)
Пример #3
0
def packager(data, feature_set, **kw):
    """Build an add-on based on input data."""
    log.info('[1@None] Packaging add-on')

    from devhub.views import packager_path
    dest = packager_path(data['slug'])

    with guard(u'devhub.packager.%s' % dest) as locked:
        if locked:
            log.error(u'Packaging in progress: %s' % dest)
            return

        with statsd.timer('devhub.packager'):
            from packager.main import packager
            log.info('Starting packaging: %s' % dest)
            features = set([k for k, v in feature_set.items() if v])
            try:
                packager(data, dest, features)
            except Exception, err:
                log.error(u'Failed to package add-on: %s' % err)
                raise
            if storage.exists(dest):
                log.info(u'Package saved: %s' % dest)
Пример #4
0
def packager(data, feature_set, **kw):
    """Build an add-on based on input data."""
    log.info('[1@None] Packaging add-on')

    from mkt.developers.views import packager_path
    dest = packager_path(data['slug'])

    with guard(u'mkt.developers.packager.%s' % dest) as locked:
        if locked:
            log.error(u'Packaging in progress: %s' % dest)
            return

        with statsd.timer('mkt.developers.packager'):
            from packager.main import packager
            log.info('Starting packaging: %s' % dest)
            features = set([k for k, v in feature_set.items() if v])
            try:
                packager(data, dest, features)
            except Exception, err:
                log.error(u'Failed to package add-on: %s' % err)
                raise
            if os.path.exists(dest):
                log.info(u'Package saved: %s' % dest)
Пример #5
0
def test_ff_overlay(_write_resource, write):
    """The files `ff-overlay.xul` and `ff-overlay.js` should appear in
    the package if Firefox is a target application.

    """
    data_ = copy.deepcopy(data)
    data_['targetapplications'][0]['guid'] = FIREFOX_GUID

    with tempfile.NamedTemporaryFile(delete=False) as t:
        try:
            temp_fn = t.name

            p.packager(data_, temp_fn, features)

            # Ensure `xpi.write(...)` was called with `ff-overlay.xul`.
            cld_name, cld_data = write.call_args_list[-1][0]
            eq_(cld_name, 'chrome/content/ff-overlay.xul')

            # Ensure `_write_resource(...)` was called with `ff-overlay.js`.
            cld_name, xpi_obj, cld_data = _write_resource.call_args_list[-1][0]
            eq_(cld_name, 'chrome/content/ff-overlay.js')
            eq_(cld_data, data_)
        finally:
            os.unlink(temp_fn)