changeset 17:557f0edc2ca4

added daily-edition commands
author Atul Varma <varmaa@toolness.com>
date Sun, 28 Mar 2010 17:00:39 -0700
parents 1fee5287e956
children 400a9edd79ad
files my-enso-commands.py
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/my-enso-commands.py	Sat Mar 27 16:12:36 2010 -0700
+++ b/my-enso-commands.py	Sun Mar 28 17:00:39 2010 -0700
@@ -932,3 +932,34 @@
 <script src=""></script>
 </html>
 """
+
+def _gen_daily_edition(ensoapi, args=""):
+    logfile = open('/tmp/daily-edition.log', 'w')
+    popen = subprocess.Popen([
+            "ssh", "labs.toolness.com",
+            "/home/varmaa/bin/publish-edition %s" % args
+            ], stdout=logfile, stderr=subprocess.STDOUT)
+    ensoapi.display_message("Please wait, this may take a while.")
+    while popen.poll() is None:
+        yield
+    logfile.close()
+    if popen.returncode:
+        ensoapi.display_message("Failed to generate edition!")
+    else:
+        retval = subprocess.call([
+                "open",
+                "-a", "/Applications/Safari.app",
+                "http://labs.toolness.com/daily-edition/"
+                ])
+        if retval:
+            ensoapi.display_message("Opening web browser failed.")
+
+def cmd_publish_new_daily_edition(ensoapi):
+    "Generates a new issue of The Daily Edition with new news."
+
+    return _gen_daily_edition(ensoapi, "--refresh-feeds")
+
+def cmd_publish_old_daily_edition(ensoapi):
+    "Generates a new issue of The Daily Edition with old news."
+
+    return _gen_daily_edition(ensoapi)