projects
/
iron-blogger
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d081d74
)
weekly-update: Add -n for dry run.
author
Nelson Elhage
<nelhage@ksplice.com>
Tue, 1 Jun 2010 00:40:47 +0000
(20:40 -0400)
committer
Nelson Elhage
<nelhage@ksplice.com>
Tue, 1 Jun 2010 00:40:47 +0000
(20:40 -0400)
weekly-update.py
patch
|
blob
|
history
diff --git
a/weekly-update.py
b/weekly-update.py
index dd217ce8b32114dc29e67373ee8543d3b78da91c..b87e37ef7e4453b04a8fc3cbc8c646b686c24802 100755
(executable)
--- a/
weekly-update.py
+++ b/
weekly-update.py
@@
-9,6
+9,13
@@
XMLRPC_ENDPOINT = 'http://iron-blogger.mit.edu/xmlrpc.php'
USER = 'nelhage'
BLOG_ID = 1
USER = 'nelhage'
BLOG_ID = 1
+args = sys.argv[1:]
+if args[0] == '-n':
+ dry_run = True
+ args = args[1:]
+
+date = args[0]
+
try:
subprocess.call(['stty', '-echo'])
passwd = raw_input("Password for %s: " % (USER,))
try:
subprocess.call(['stty', '-echo'])
passwd = raw_input("Password for %s: " % (USER,))
@@
-16,16
+23,14
@@
try:
finally:
subprocess.call(['stty', 'echo'])
finally:
subprocess.call(['stty', 'echo'])
-x = xmlrpclib.ServerProxy(XMLRPC_ENDPOINT)
-
with open('ledger', 'a') as f:
f.write("\n")
with open('ledger', 'a') as f:
f.write("\n")
- f.write(render.render_template('templates/ledger',
sys.argv[1]
))
+ f.write(render.render_template('templates/ledger',
date
))
subprocess.check_call(["git", "commit", "ledger",
subprocess.check_call(["git", "commit", "ledger",
- "-m", "Update for %s" % (
sys.argv[1]
,)])
+ "-m", "Update for %s" % (
date
,)])
-text = render.render_template('templates/week.tmpl',
sys.argv[1]
)
+text = render.render_template('templates/week.tmpl',
date
)
lines = text.split("\n")
title = lines[0]
lines = text.split("\n")
title = lines[0]
@@
-34,8
+39,15
@@
body = "\n".join(lines[1:])
page = dict(title = title,
description = body)
page = dict(title = title,
description = body)
-x.metaWeblog.newPost(BLOG_ID, USER, passwd, page, True)
+if not dry_run:
+ x = xmlrpclib.ServerProxy(XMLRPC_ENDPOINT)
+ x.metaWeblog.newPost(BLOG_ID, USER, passwd, page, True)
+
+email = render.render_template('templates/email.txt', date)
-p = subprocess.Popen(['mutt', '-H', '/dev/stdin'],
- stdin=subprocess.PIPE)
-p.communicate(render.render_template('templates/email.txt', sys.argv[1]))
+if dry_run:
+ print email
+else:
+ p = subprocess.Popen(['mutt', '-H', '/dev/stdin'],
+ stdin=subprocess.PIPE)
+ p.communicate(email)
Benjamin Mako Hill
||
Want to submit a patch?