Skip to content

Instantly share code, notes, and snippets.

@fwenzel
Forked from jbalogh/new-addon.py
Created December 11, 2009 21:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwenzel/254549 to your computer and use it in GitHub Desktop.
Save fwenzel/254549 to your computer and use it in GitHub Desktop.
Create a new, random add-on through the AMO add-on builder
import httplib
import urllib
import uuid
ROOT = 'addons.mozilla.org'
BUILDER_URL = '/en-US/developers/tools/builder/'
params_ = {
'name': 'unst unst',
'description': 'stephend ftw',
'version': '1.0',
'id': '{%s}' % uuid.uuid4(),
'package': 'stephend',
'author': 'Stephen Donner',
'applications[]': 'firefox',
'firefox_min': '3.5b4',
'firefox_max': '3.7a1pre',
'ui[]': 'about',
'contributors': '',
}
# Have to fill these out or the form looks invalid.
for app in ('thunderbird', 'sunbird', 'mobile'):
params_[app + '_min'] = params_[app + '_max'] = '0.7'
# seamonkey is *always* a fucking special case.
params_['seamonkey_min'] = params_['seamonkey_max'] = '1.0'
def main():
params = urllib.urlencode(params_)
headers = {'Content-type': 'application/x-www-form-urlencoded'}
conn = httplib.HTTPSConnection(ROOT)
conn.request('POST', BUILDER_URL, params, headers)
response = conn.getresponse()
hash = response.getheader('location').rsplit('/', 1)[1]
response.close()
conn.request('GET', '%s/downloads/%s' % (BUILDER_URL, hash))
response = conn.getresponse()
open('stephen.xpi', 'w').write(response.read())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment