src/hg/encode/encodeCharts/encodeTimeline.py 1.2

1.2 2010/04/07 23:13:58 bsuh
Script now specifies path to 2.6 version of Python. Added stuff to make it a cgi-bin script
Index: src/hg/encode/encodeCharts/encodeTimeline.py
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/encode/encodeCharts/encodeTimeline.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/encode/encodeCharts/encodeTimeline.py	7 Apr 2010 19:10:30 -0000	1.1
+++ src/hg/encode/encodeCharts/encodeTimeline.py	7 Apr 2010 23:13:58 -0000	1.2
@@ -1,13 +1,16 @@
-#!/usr/bin/env python
+#!/hive/groups/recon/local/bin/python
 
+import cgitb
 import datetime
 import os
 import re
 import sys
 
 import gviz_api
 
+cgitb.enable()
+
 # Directory containing the report files
 reportDir = "/hive/groups/encode/dcc/reports"
 
 # File listing the important events and dates
@@ -42,9 +45,9 @@
   if currentFile == "NULL":
     print >> sys.stderr, "Error: Can't find a report file in dir '%s'" % reportDir
     sys.exit(-1)
 
-  return currentFile
+  return currentFile, currentDate
 
 # Read and parse the important dates file
 # Return a dict where key = event date and value = event label
 def readImportantDatesFile (file):
@@ -92,9 +95,9 @@
   importantDateHash = readImportantDatesFile(importantDatesFile)
 
   submitHash = {}
   releaseHash = {}
-  currentFile = getRecentReport(reportDir)
+  currentFile, currentDate = getRecentReport(reportDir)
   fullFilePath = reportDir + "/" + currentFile
 
   try:
     f = open(fullFilePath, "r")
@@ -167,9 +170,9 @@
     array.append(submitSum)
     array.append(annotText)
     dataArray.append(array)
 
-  return dataArray
+  return dataArray, currentDate
 
 def main():
   # Headers for the columns in the data matrix
   description = [("date", "date"), ("release", "number"), ("release_cumul", "number"), ("submit", "number"), ("submit_cumul", "number"), ("events", "string") ]
@@ -177,17 +180,21 @@
   # Create the data table 
   data_table = gviz_api.DataTable(description)
 
   # Create and load the matrix
-  matrix = getDataArray(reportDir, importantDatesFile)
+  matrix, reportDate = getDataArray(reportDir, importantDatesFile)
   data_table.LoadData(matrix)
 
+  reportDate = str(reportDate)
+  reportDateObj = datetime.date(int(reportDate[0:4]), int(reportDate[4:6]), int(reportDate[6:8]))
+  dateStamp = reportDateObj.strftime("%b %d, %Y")
+
   # Convert to JavaScript code
   jscode = data_table.ToJSCode("jscode_data")
 
   # Commented out but could serve this page dynamically
-#  print "Content-type: text/html"
-#  print
+  print "Content-type: text/html"
+  print
 
   # Print out the webpage
   print page_template % vars()
 
@@ -212,8 +219,9 @@
     <title>ENCODE Cumulative Submit and Release Timeline</title>
   </head>
 
   <body>
+    <h2>ENCODE Cumulative Submit and Release Timeline <br><font size="-1">(Report Date: %(dateStamp)s)</font></h2>
     <div id='chart_div' style='width: 854px; height: 480px;'></div>
   </body>
 </html>
 """