diff options
author | Rob Austein <sra@hactrn.net> | 2010-10-25 19:49:56 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-10-25 19:49:56 +0000 |
commit | 16db3e7c15aab40fbdb5b9542e8794b3101419bf (patch) | |
tree | 29c9f781ada41c9ecfc46ce6d26c6e39d015d75d /scripts | |
parent | ce4bbe5f6acc92865b49b47bd6bdc13343d88d25 (diff) |
Checkpoint
svn path=/scripts/rpkidemo; revision=3486
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/rpkidemo | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/scripts/rpkidemo b/scripts/rpkidemo index 19377777..e1f70eae 100755 --- a/scripts/rpkidemo +++ b/scripts/rpkidemo @@ -45,10 +45,11 @@ cwd = os.getcwd() # Parameters that perhaps we should be getting from a config file. # Just wiring in for now, to get them all in one place. -base_url = "http://some.where.example/rpki/blah/" +base_url = "http://demo.rpki.net/gui/" example_myrpki_cfg = "%s/rpkid/examples/myrpki.conf" % top working_dir = "%s/rpkidemo-data" % cwd myrpki_py = "%s/rpkid/myrpki.py" % top +user_agent = "RPKIDemo" # Find or build a usable copy of OpenSSL @@ -94,20 +95,23 @@ cookie_handler = urllib2.HTTPCookieProcessor() auth_handler = urllib2.HTTPDigestAuthHandler() auth_handler.add_password( realm = None, - uri = base_uri, + uri = base_url, user = username, passwd = password) -opener = urllilb2.build_opener(cookie_handler, auth_handler) +opener = urllib2.build_opener(cookie_handler, auth_handler) # Create working directory and move to it. try: + print "Creating", working_dir os.mkdir(working_dir) except OSError, e: if e.errno != errno.EEXIST: raise + print working_dir, "already exists, reusing it" os.chdir(working_dir) # Generate config file +print "Generating myrpki.conf" section_regexp = re.compile("\s*\[\s*(.+?)\s*\]\s*$") variable_regexp = re.compile("\s*([-a-zA-Z0-9_]+)\s*=\s*(.+?)\s*$") f = open("myrpki.conf", "w") @@ -119,11 +123,12 @@ for line in open(example_myrpki_cfg): section = m.group(1) m = variable_regexp.match(line) option = m.group(1) if m and section == "myrpki" else None + value = m.group(2) if option else None if option == "handle": line = "handle = %s\n" % username if option == "openssl": line = "openssl = %s\n" % openssl - if option in ("run_rpkid", "run_pubd", "run_rootd"): + if option in ("run_rpkid", "run_pubd", "run_rootd") and value != "false": line = "%s = false\n" % option f.write(line) f.close() @@ -135,11 +140,12 @@ def upload(url, filename): """ Upload filename to URL, return result. """ - return opener(urllib2.Request( - base_url + url, - open(filename).read(), - { "Content-Type" : "Application/XML", - "User-Agent" : "RPKIDemo" })) + url = base_url + url + data = open(filename).read() + print "Uploading", filename, "to", url + return opener.open(urllib2.Request(url, data, { + "Content-Type" : "Application/XML", + "User-Agent" : user_agent })) def poll(filename, url): """ @@ -147,11 +153,10 @@ def poll(filename, url): return boolean indicating whether file changed. """ try: - r = opener(urllib2.Request( - base_url + url, - None, - { "If-Modified-Since" : blah_blah_date_voodoo(filename), - "User-Agent" : "RPKIDemo" })) + url = base_url + url + r = opener.open(urllib2.Request( url, None, { + "If-Modified-Since" : blah_blah_date_voodoo(filename), + "User-Agent" : user_agent })) save(filename, r.read()) blah_blah_more_date_voodoo(filename, r.info().getheader("Last-Modified")) return True |