Exemplo n.º 1
0
def main():
  form = cgi.FieldStorage()
  # CGI variables:
  #   key = project, lab, data, freeze, status

  keyField = form.getvalue('key')
  if not keyField:
    keyField = 'project'

  switch = {'project':0, 'lab':1, 'data':2, 'freeze':5, 'status':8 }
  titleTag = {'project':"Project", 'lab':"Lab", 'data':"Data_Type", 
              'freeze':"Freeze", 'status':"Status" }
  if keyField not in switch:
    keyField = 'project'
  keyIndex = switch[keyField]

  reportFile, currentDate = encodeReportLib.getRecentReport()
  matrix, labels = processReportFile(reportFile, keyIndex)

  # Headers for the columns in the data matrix
  description = [("Time", "string")]
  for label in labels:
    tmpDesc = [(label, 'number')]
    description += tmpDesc

  # Create the data table
  data_table = gviz_api.DataTable(description)
  data_table.LoadData(matrix)

  # Convert to JavaScript code
  jscode = data_table.ToJSCode("jscode_data")

  # Set variables for HTML output
  template_vars = {}
  template_vars['jscode'] = jscode
  template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate)
  template_vars['title'] = "ENCODE Amount of Time Until Release by %s" % titleTag[keyField]
  template_vars['packageName'] = 'columnchart'
  template_vars['visClass'] = 'ColumnChart'
  template_vars['style'] = ""

  # Set the chart specific configuration options
  chart_config = {}
  chart_config['isStacked'] = 'true'
  chart_config['legendFontSize'] = 16
  chart_config['width'] = 1200
  chart_config['height'] = 480
  chart_config['legend'] = 'bottom'
  chart_config['titleX'] = '# of Weeks'
  chart_config['titleY'] = '# of Submissions'
  chart_config['tooltipFontSize'] = 16

  if (keyField == 'freeze'):
    chart_config['colors'] = encodeReportLib.getColorArray(len(labels))

  template_vars['chart_config'] = json.dumps(chart_config)

  encodeReportLib.renderHtml(template_vars, 1, 0)

  return
Exemplo n.º 2
0
def main():
  form = cgi.FieldStorage()
  # CGI Variables
  #   key = project, lab, data, freeze, or species
  #     Display data based on the key variable
  #   norelease = 0 or 1
  #     0 = Output all data
  #     1 = Output only unreleased data
  #   species = human, mouse, all
  #     human = Output only human data
  #     mouse = Output only mouse data
  #     all   = Output all data

  keyField = form.getvalue('key')
  if keyField == None:
    keyField = 'project'
  norelease = form.getvalue('norelease')
  if norelease == None:
    norelease = 0
  norelease = int(norelease)
  species = form.getvalue('species')
  if species == None:
    species = 'all'

  switch = {'project':0, 'lab':1, 'data':2, 'freeze':5, 'status':8}
  titleTag = {'project':"Project", 'lab':"Lab", 'data':"Data_Type", 
              'freeze':"Freeze", 'status':"Status"}
  if keyField not in switch:
    keyField = 'project'
  keyIndex = switch[keyField]

  # Headers for the columns in the data matrix
  description = [(titleTag[keyField], "string")]
  fullLabel = ['released', 'reviewing', 'approved', 'displayed', 'downloads', 'loaded']
  statusLabel = []
  for label in fullLabel:
    if label == 'released' and norelease == 1:
      continue
    tmpDesc = [(label, 'number')]
    description += tmpDesc
    statusLabel.append(label)

  reportFile, currentDate = encodeReportLib.getRecentReport()
  matrix = processReportFile(reportFile, statusLabel, keyIndex, norelease, 
                             species)

  # Create the data table
  data_table = gviz_api.DataTable(description)
  data_table.LoadData(matrix)

  # Convert to JavaScript code
  jscode = data_table.ToJSCode("jscode_data")

  # Set variables for HTML output
  template_vars = {}
  template_vars['jscode'] = jscode
  template_vars['dateStamp'] = encodeReportLib.dateIntToDateStr(currentDate)
  template_vars['title'] = "ENCODE (%s) Status by %s" % (species, 
                                                         titleTag[keyField])
  template_vars['packageName'] = 'columnchart'
  template_vars['visClass'] = 'ColumnChart'
  template_vars['style'] = ""
  template_vars['species'] = species
  template_vars['keyField'] = keyField
  template_vars['norelease']= norelease

  # Set the chart specific configuration options
  chart_config = {}
  chart_config['isStacked'] = 'true'
  chart_config['legendFontSize'] = 16
  chart_config['width'] = 854
  chart_config['height'] = 480
  chart_config['titleX'] = titleTag[keyField]
  chart_config['titleY'] = "# of Submissions"
  chart_config['tooltipFontSize'] = 16
  chart_config['enableTooltip'] = 'true'
  colors = encodeReportLib.getColorArray(len(statusLabel))
  colors.reverse()
  chart_config['colors'] = colors

  template_vars['chart_config'] = json.dumps(chart_config)

  encodeReportLib.renderHtml(template_vars, 0, 1)

  return