Created
December 8, 2009 22:55
-
-
Save jbalogh/252076 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import httplib | |
import urllib | |
ROOT = 'addons.mozilla.org' | |
BUILDER_URL = '/en-US/developers/tools/builder/' | |
params_ = { | |
'name': 'unst unst', | |
'description': 'heart stephend', | |
'version': '1.0', | |
'id': 'stephend.%s' % datetime.now().strftime('%Y.%m.%d.%H.%M.%S'), | |
'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