2

I try to update the Firefox Marketplace entry of an app programatically via the Python API. I am able to successfully upload screenshots using the client.create_screenshot(app_id, filename) method from the module marketplace against the development environment at https://marketplace-dev.allizom.org/.

Within the Python API there is no method to upload the Icon. In the Marketplace API documentation though, there is a REST point to upload the icon: Updating an App Icon

I used the documentation to write my own method to upload the icon:

import mimetypes
import sys
from base64 import b64encode
from urlparse import urlunparse

def post_icon_file(client, app_id, filename):
  with open(filename, 'rb') as s_file:
    s_content = s_file.read()
    s_encoded = b64encode(s_content)
    url = urlunparse((client.protocol, '%s:%s' % (client.domain, client.port),
      '%s/api/v2%s' % (client.prefix, '/apps/app/' + str(app_id) + '/icon/'),
      '', '', ''))

    print url

    mtype, encoding = mimetypes.guess_type(filename)
    if mtype is None:
      mtype = 'image/jpeg'

    data = {'file': {
      'type': mtype,
      'data': s_encoded
    }}

    response = client.conn.fetch('PUT', url, data)

    if response.status_code != 200:
      sys.exit(response.content)
    else:
      print str(response.status_code) + ': Uploaded icon ' + filename + ' for app ID ' + str(app_id)

Problem: The response of the upload is a success (200). I get the message:

200: Uploaded icon /path/to/icon/icon-512.png for app ID 1234567

Still in the Marketplace entry at https://marketplace-dev.allizom.org/developers/app/[slug]/edit, the App Icon is shown as the default icon

My Investigation so far:

  1. If I get the status of the app via client.status(app_id) the entries for the icons are still the default ones, e.g.: icons: {u\'128\': u\'https://marketplace-dev-cdn.allizom.org/media/img/hub/default-128.png\'

  2. I tried to upload an icon in the size of 128 by 128 pixels and another one in 512 by 512 pixels. Both have the same result: success, but they are not changed in the entry.

Rias
  • 1,956
  • 22
  • 33

1 Answers1

1

Try deploy your Zamboni [1] instance and [2] file a bug and make pull request. You can see bugs like this in the past [3]

[1] https://github.com/mozilla/zamboni

[2] https://bugzilla.mozilla.org/enter_bug.cgi#h=dupes|Marketplace

[3] https://github.com/mozilla/zamboni/pull/2403

  • Do you mean that I should fork Zamboni and see if I can reproduce the Bug in my clone? – Rias Apr 07 '15 at 12:11
  • I meam fork Zamboni and try fix the bug. Or only file a bug in bugzilla. – Alexander Salas Bastidas Apr 08 '15 at 01:06
  • 1
    Thanks alexandersalas. I couldn't reproduce the bug in Zamboni on my local machine. But I filed a bug here and commented appropriately: https://bugzilla.mozilla.org/show_bug.cgi?id=1153669 – Rias Apr 14 '15 at 11:37