SF.net SVN: opencsw:[686] buildfarm/bin

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Mar 23 09:49:22 CET 2015


Revision: 686
          http://sourceforge.net/p/opencsw/code/686
Author:   wahwah
Date:     2015-03-23 08:49:22 +0000 (Mon, 23 Mar 2015)
Log Message:
-----------
Python module report modified to work from the common dir.

Modified Paths:
--------------
    buildfarm/bin/python-module-report-html-helper.py
    buildfarm/bin/python-module-report.sh

Modified: buildfarm/bin/python-module-report-html-helper.py
===================================================================
--- buildfarm/bin/python-module-report-html-helper.py	2015-03-22 16:33:47 UTC (rev 685)
+++ buildfarm/bin/python-module-report-html-helper.py	2015-03-23 08:49:22 UTC (rev 686)
@@ -1,5 +1,6 @@
 #!/opt/csw/bin/python2.6
 
+import argparse
 import cjson
 import re
 import copy
@@ -17,82 +18,110 @@
     'CSWpython27-dev',
 ])
 
-with open('list_legacy.txt', 'r') as fd:
-  pkgs_legacy = re.split(r'\s+', fd.read())
+def main():
+  parser = argparse.ArgumentParser(description='Python modules report')
+  parser.add_argument('--legacy-modules', dest='mod_legacy',
+                      default='list_legacy.txt')
+  parser.add_argument('--26-modules', dest='mod_26', default='list_26.txt')
+  parser.add_argument('--27-modules', dest='mod_27', default='list_27.txt')
+  parser.add_argument('--html-output', dest='html_file')
+  parser.add_argument('--json-output', dest='json_file')
 
-with open('list_26.txt', 'r') as fd:
-  pkgs_26 = re.split(r'\s+', fd.read())
+  args = parser.parse_args()
 
-with open('list_27.txt', 'r') as fd:
-  pkgs_27 = re.split(r'\s+', fd.read())
+  with open(args.mod_legacy, 'r') as fd:
+    pkgs_legacy = re.split(r'\s+', fd.read())
 
-pkgs_legacy = set(pkgs_legacy)
-pkgs_26 = set(pkgs_26)
-pkgs_27 = set(pkgs_27)
+  with open(args.mod_26, 'r') as fd:
+    pkgs_26 = re.split(r'\s+', fd.read())
 
-total_pkgs = copy.copy(pkgs_legacy)
-total_pkgs = total_pkgs.union(pkgs_26)
-total_pkgs = total_pkgs.union(pkgs_27)
+  with open(args.mod_27, 'r') as fd:
+    pkgs_27 = re.split(r'\s+', fd.read())
 
-TEMPLATE = """<html>
-<body>
-<head>
-<style TYPE="text/css">
-table { border-collapse:collapse; }
-table, th, td { border: 1px solid black; }
-th, td { padding: 4px; }
-</style>
-<title>Python module status</title>
-</head>
-<body>
-<p>Last update: {{ lastupdate }}.</p>
-<p>{{ table|length }} packages total</p>
-<table>
-<tr>
-  <th>pkgname</th>
-  <th>status</th>
-</tr>
-{% for pkgname, status, color in table %}
-<tr style="color: {{ color }};">
-  <td><a href="http://www.opencsw.org/packages/{{ pkgname }}">{{ pkgname }}</a></td>
-  <td>{{ status }}</td>
-</tr>
-{% endfor %}
-</table>
-</body>
+  pkgs_legacy = set(pkgs_legacy)
+  pkgs_26 = set(pkgs_26)
+  pkgs_27 = set(pkgs_27)
+
+  total_pkgs = copy.copy(pkgs_legacy)
+  total_pkgs = total_pkgs.union(pkgs_26)
+  total_pkgs = total_pkgs.union(pkgs_27)
+
+  TEMPLATE = """
+<!DOCTYPE html>
+<html>
+  <head>
+    <script type='text/javascript' src='https://www.google.com/jsapi'></script>
+    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
+    <script type='text/javascript'>
+      google.load('visualization', '1', {packages:['table']});
+      function PopulateTable(datareturned) {
+        var data = new google.visualization.DataTable();
+        var processedData = [];
+        for (var row in datareturned) {
+          processedData.push([
+              datareturned[row][0],
+              datareturned[row][1],
+              // {p: {style: 'color: ' + datareturned[row][2]}, f: datareturned[row][1]},
+          ]);
+        }
+        data.addColumn('string', 'Package');
+        data.addColumn('string', 'Status');
+        // data.addColumn('string', 'Color');
+        data.addRows(processedData);
+
+        var table = new google.visualization.Table(document.getElementById('table_div'));
+        table.draw(data, {showRowNumber: true});
+      }
+      function getTableData() {
+        $.getJSON('python-modules.json', PopulateTable);
+      }
+      google.setOnLoadCallback(getTableData);
+    </script>
+  </head>
+
+  <body>
+    <h1>Python packages</h1>
+    <p>All the legacy packages (see the second column) are the ones that put files in the
+    /opt/csw/lib/python/site-packages dictory and need to be rebuilt.</p>
+    <p>Last updated {{ lastupdate }}</p>
+    <div id='table_div'></div>
+  </body>
 </html>
-"""
+  """
 
-table = []
+  table = []
 
-for pkg in sorted(total_pkgs):
-  pkg = pkg.strip()
-  if not pkg:
-    continue
-  if pkg in STOPLIST:
-    continue
-  status = None
-  color = None
-  if pkg in pkgs_legacy:
-    status = 'legacy'
-    color = 'red'
-  elif pkg in pkgs_26 and pkg not in pkgs_27:
-    status = '2.6 only'
-    color = 'green'
-  elif pkg in pkgs_27 and pkg not in pkgs_26:
-    status = '2.7 only'
-    color = 'green'
-  elif pkg in pkgs_26 and pkg in pkgs_26:
-    status = 'dual'
-    color = 'green'
-  table.append((pkg, status, color))
+  for pkg in sorted(total_pkgs):
+    pkg = pkg.strip()
+    if not pkg:
+      continue
+    if pkg in STOPLIST:
+      continue
+    status = None
+    color = None
+    if pkg in pkgs_legacy:
+      status = 'legacy'
+      color = 'red'
+    elif pkg in pkgs_26 and pkg not in pkgs_27:
+      status = '2.6 only'
+      color = 'green'
+    elif pkg in pkgs_27 and pkg not in pkgs_26:
+      status = '2.7 only'
+      color = 'green'
+    elif pkg in pkgs_26 and pkg in pkgs_26:
+      status = 'dual'
+      color = 'green'
+    table.append((pkg, status, color))
 
-template = jinja2.Template(TEMPLATE)
+  template = jinja2.Template(TEMPLATE)
 
-lastupdate = str(datetime.datetime.now())
+  lastupdate = str(datetime.datetime.now())
 
-# with open("/home/maciej/public_html/python-modules.html", "w") as fd:
-#   fd.write(template.render(table=table, lastupdate=lastupdate))
+  with open(args.html_file, 'w') as fd:
+    fd.write(template.render(table=table, lastupdate=lastupdate))
 
-with open('/home/maciej/public_html/python-modules.json', 'w') as fd:
-  fd.write(cjson.encode(table))
+  with open(args.json_file, 'w') as fd:
+    fd.write(cjson.encode(table))
+
+if __name__ == '__main__':
+  main()

Modified: buildfarm/bin/python-module-report.sh
===================================================================
--- buildfarm/bin/python-module-report.sh	2015-03-22 16:33:47 UTC (rev 685)
+++ buildfarm/bin/python-module-report.sh	2015-03-23 08:49:22 UTC (rev 686)
@@ -1,14 +1,30 @@
 #!/opt/csw/bin/bash
+#
+# Report of Python packages built for version 2.6, 2.7 and dual.
 
+set -u
+set -e
+
+CATALOGS_URL="http://buildfarm.opencsw.org/pkgdb/rest/catalogs/"
+BASE_URL="$CATALOGS_URL/unstable/i386/SunOS5.10/pkgnames-and-paths-by-basedir"
+REPORT_DIR="/opt/csw/apache2/share/htdocs/buildfarm/obsolete-pkgs"
+TOOLS_DIR="/home/web/bin"
+
 function pkg_in_dir() {
-  /opt/csw/bin/curl -s "http://buildfarm.opencsw.org/pkgdb/rest/catalogs/unstable/i386/SunOS5.10/pkgnames-and-paths-by-basedir?basedir=$1" \
-    | /opt/csw/bin/python2.6 -c "import cjson; import sys; print '\n'.join(sorted(cjson.decode(sys.stdin.read())))";
+  /opt/csw/bin/curl -s "${BASE_URL}?basedir=$1" \
+    | /opt/csw/bin/python2.6 -c \
+    "import cjson; import sys; print '\n'.join(sorted(cjson.decode(sys.stdin.read())))";
 }
 
-cd /home/maciej/src/project-status
+pkg_in_dir /opt/csw/lib/python > "${REPORT_DIR}/list_legacy.txt"
+pkg_in_dir /opt/csw/lib/python2.6 > "${REPORT_DIR}/list_26.txt"
+pkg_in_dir /opt/csw/lib/python2.7 > "${REPORT_DIR}/list_27.txt"
 
-pkg_in_dir /opt/csw/lib/python > list_legacy.txt
-pkg_in_dir /opt/csw/lib/python2.6 > list_26.txt
-pkg_in_dir /opt/csw/lib/python2.7 > list_27.txt
+trap 'rm -f ${REPORT_DIR}/list_{legacy,26,26}.txt' EXIT
 
-/opt/csw/bin/python2.6 /home/maciej/src/project-status/compose_html.py
+/opt/csw/bin/python2.6 "$TOOLS_DIR/python-module-report-html-helper.py" \
+  --legacy-modules="${REPORT_DIR}/list_legacy.txt" \
+  --26-modules="${REPORT_DIR}/list_26.txt" \
+  --27-modules="${REPORT_DIR}/list_27.txt" \
+  --html-output="${REPORT_DIR}/python-modules.html" \
+  --json-output="${REPORT_DIR}/python-modules.json"

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the devel mailing list