Skip to content

Instantly share code, notes, and snippets.

@jamiejackson
Created September 10, 2014 22:14
Show Gist options
  • Save jamiejackson/5c95f8773efc1051ed7c to your computer and use it in GitHub Desktop.
Save jamiejackson/5c95f8773efc1051ed7c to your computer and use it in GitHub Desktop.
#!/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
@jamiejackson
Copy link
Author

Note, this doesn't work. The "Add Extension" part is hard to emulate through automation, and I haven't figured it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment