Created
September 10, 2014 22:14
-
-
Save jamiejackson/5c95f8773efc1051ed7c to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
import mechanize, sys, urllib, time | |
#print mechanize.Browser().handlers | |
br = mechanize.Browser() | |
#i | |
br.set_handle_redirect(mechanize.HTTPRedirectHandler) | |
##### Authenticate ############################################################# | |
response = br.open("https://local.mysite.com/railo-context/admin/web.cfm") | |
br.select_form("login"); | |
br.form.find_control("login_passwordweb").value = "password" | |
br.submit() | |
#==============================================================================# | |
##### Add Extension Provider ################################################### | |
# "New Extension Provider" form | |
time.sleep(3) | |
br.open("https://local.mysite.com/railo-context/admin/web.cfm?action=extension.providers") | |
br.form = list(br.forms())[2] # third form on page (it's pseudo-randomly named, so its name isn't usable) | |
br.form.find_control("url_1").value = "http://www.andyjarrett.co.uk/RailoExtensionProvider/ExtensionProvider.cfc" | |
br.submit() | |
#==============================================================================# | |
##### Add Extension ############################################################ | |
time.sleep(10) | |
br.open("https://local.mysite.com/railo-context/admin/web.cfm?mainAction=extension.applications&uid=90744C015F1643379D94B3E9C1558E0C") | |
time.sleep(10) | |
br.open("https://local.mysite.com/railo-context/admin/web.cfm?action=extension.applications&uid=90744C015F1643379D94B3E9C1558E0C&action2=install1") | |
time.sleep(10) | |
br.open("https://local.mysite.com/railo-context/admin/web.cfm?action=extension.applications&uid=90744C015F1643379D94B3E9C1558E0C&action2=install2") #&action2=install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, this doesn't work. The "Add Extension" part is hard to emulate through automation, and I haven't figured it out.