MoinMessage

Annotated tests/test_post.py

138:42a242ec2c6b
2015-04-11 Paul Boddie Exit the fetch script if communication fails. gpgutils
paul@0 1
#!/usr/bin/env python
paul@0 2
paul@12 3
from MoinMessage import parseURL
paul@0 4
import httplib
paul@0 5
import sys
paul@0 6
paul@0 7
if __name__ == "__main__":
paul@12 8
    url = sys.argv[1] + "?action=PostMessage"
paul@0 9
paul@5 10
    text = sys.stdin.read()
paul@12 11
    scheme, host, port, path = parseURL(url)
paul@0 12
paul@12 13
    if scheme != "http":
paul@12 14
        print >>sys.stderr, "Only http URLs are supported."
paul@12 15
        sys.exit(1)
paul@12 16
paul@12 17
    req = httplib.HTTPConnection(host, port)
paul@0 18
    req.request("PUT", path, text) # {"Content-Length" : len(text)}
paul@0 19
    resp = req.getresponse()
paul@0 20
    print resp.read()
paul@0 21
paul@0 22
# vim: tabstop=4 expandtab shiftwidth=4