]> projects.mako.cc - iron-blogger/blob - weekly-update.py
Commit the right thing in the weekly update.
[iron-blogger] / weekly-update.py
1 #!/usr/bin/python
2 import render
3 import os
4 import sys
5 import xmlrpclib
6 import subprocess
7
8 XMLRPC_ENDPOINT = 'http://iron-blogger.mit.edu/xmlrpc.php'
9 USER            = 'nelhage'
10 BLOG_ID         = 1
11
12 try:
13     subprocess.call(['stty', '-echo'])
14     passwd = raw_input("Password for %s: " % (USER,))
15     print
16 finally:
17     subprocess.call(['stty', 'echo'])
18
19 x = xmlrpclib.ServerProxy(XMLRPC_ENDPOINT)
20
21 with open('ledger', 'a') as f:
22     f.write("\n")
23     f.write(render.render_template('templates/ledger', sys.argv[1]))
24
25 subprocess.check_call(["git", "commit", "ledger",
26                        "-m", "Update for %s" % (sys.argv[1],)])
27
28 text = render.render_template('templates/week.tmpl', sys.argv[1])
29
30 lines = text.split("\n")
31 title = lines[0]
32 body  = "\n".join(lines[1:])
33
34 page = dict(title = title,
35             description = body)
36
37 x.metaWeblog.newPost(BLOG_ID, USER, passwd, page, True)
38
39 p = subprocess.Popen(['mutt', '-H', '/dev/stdin'],
40                      stdin=subprocess.PIPE)
41 p.communicate(render.render_template('templates/email.txt', sys.argv[1]))

Benjamin Mako Hill || Want to submit a patch?