aboutsummaryrefslogtreecommitdiff
path: root/potpourri/rrdp-fetch-from-tal
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-07-21 14:05:44 +0000
committerRob Austein <sra@hactrn.net>2015-07-21 14:05:44 +0000
commitd9bd71463fc2d47503c3300b3a207a7b8124d8b6 (patch)
tree9031d4234c008fbc5ff51fe8f3d4ac4f3b57b623 /potpourri/rrdp-fetch-from-tal
parent6730c76fbf4c698ff5cdc730df424701113ef165 (diff)
Start catching up on six months worth of little changes in RRDP.
svn path=/branches/tk705/; revision=6081
Diffstat (limited to 'potpourri/rrdp-fetch-from-tal')
-rwxr-xr-xpotpourri/rrdp-fetch-from-tal26
1 files changed, 26 insertions, 0 deletions
diff --git a/potpourri/rrdp-fetch-from-tal b/potpourri/rrdp-fetch-from-tal
index 0a97955e..08d245dd 100755
--- a/potpourri/rrdp-fetch-from-tal
+++ b/potpourri/rrdp-fetch-from-tal
@@ -40,6 +40,32 @@ class Tags(object):
tags = Tags("notification", "delta", "snapshot", "publish", "withdraw")
+class RSyncHandler(urllib2.BaseHandler):
+ """
+ Jam support for rsync:// URIs into urllib2 framework.
+ Very basic, probably not paranoid enough.
+ """
+
+ _n = 0
+
+ def rsync_open(self, req):
+ import subprocess, mimetools
+ u = req.get_full_url()
+ if u.endswith("/"):
+ raise urllib2.URLError("rsync directory URI not allowed")
+ t = "/tmp/rrdp-fetch-from-tal.%d.%d" % (os.getpid(), self._n)
+ self._n += 1
+ subprocess.check_call(("rsync", u, t))
+ h = mimetools.Message(open("/dev/null"))
+ h["Content-type"] = "text/plain"
+ h["Content-length"] = str(os.stat(t).st_size)
+ f = open(t, "rb")
+ os.unlink(t)
+ return urllib2.addinfourl(f, h, u)
+
+urllib2.install_opener(urllib2.build_opener(RSyncHandler))
+
+
class main(object):
def __init__(self):