[Secure-testing-commits] r32511 - bin

Holger Levsen holger at moszumanska.debian.org
Thu Feb 26 15:49:47 UTC 2015


Author: holger
Date: 2015-02-26 15:49:47 +0000 (Thu, 26 Feb 2015)
New Revision: 32511

Modified:
   bin/tracker_service.py
Log:
actually create json, not yaml. probably it would be better to first aggregate the data more and then use a json library to create json...

Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py	2015-02-26 15:49:46 UTC (rev 32510)
+++ bin/tracker_service.py	2015-02-26 15:49:47 UTC (rev 32511)
@@ -138,7 +138,7 @@
         self.register('data/funny-versions', self.page_data_funny_versions)
         self.register('data/fake-names', self.page_data_fake_names)
         self.register('data/pts/1', self.page_data_pts)
-        self.register('data/yaml', self.page_yaml)
+        self.register('data/json', self.page_json)
         self.register('debsecan/**', self.page_debsecan)
         self.register('data/report', self.page_report)
         self.register('style.css', self.page_style_css)
@@ -1227,7 +1227,7 @@
             data.append('\n')
         return BinaryResult(''.join(data),'application/octet-stream')
 
-    def page_yaml(self, path, params, url):
+    def page_json(self, path, params, url):
 
         packages = []
         issues = {}
@@ -1299,22 +1299,30 @@
                 nodsa[pkg][issue][repository] = db_nodsa
 
         data = []
+        data.append('{\n')
         for pkg in packages:
-            data.append(pkg+':\n')
+            data.append('  "package": "'+pkg+'",\n')
+            data.append('    "issues": [\n')
             for issue in issues[pkg]:
-                data.append('  '+issue+':\n')
+                data.append('      {\n')
+                data.append('        "issue": "'+issue+'",\n')
                 if descriptions[issue]:
-                    data.append('    description: '+descriptions[issue]+'\n')
+                    data.append('        "description": "'+descriptions[issue]+'",\n')
                 if debianbugs[pkg][issue] != None:
-                    data.append('    debian bug: '+str(debianbugs[pkg][issue])+'\n')
+                    data.append('        "debian bug": '+str(debianbugs[pkg][issue])+',\n')
                 if str(remote[pkg][issue]) == 'None':
-                    data.append('    range: no data\n')
+                    data.append('        "range": null,\n')
                 elif remote[pkg][issue] == 1:
-                    data.append('    range: remote\n')
+                    data.append('        "range": "remote",\n')
                 else:
-                    data.append('    range: local\n')
+                    data.append('        "range": "local",\n')
+                data.append('        "repositories": [\n')
                 for repository in repositories[pkg][issue]:
-                    data.append('    '+repository+': '+version[pkg][issue][repository]+'\n')
+                    data.append('          {\n')
+                    data.append('            "'+repository+'": "'+version[pkg][issue][repository]+'"\n')
+                    data.append('          },\n')
+                data.append('        ],\n')
+                data.append('        "releases": [\n')
                 for release in releases[pkg][issue]:
                     winner=''
                     for suffix in ('','-security','-lts'):
@@ -1326,17 +1334,24 @@
                             elif status[pkg][issue][subrelease] > 0 and winner == '':
                                 winner=suffix
                     repository=release+winner
-                    data.append('       '+release+'\n')
-                    data.append('        repository: '+repository+'\n')
-                    data.append('        version: '+version[pkg][issue][repository]+'\n')
+                    data.append('          "'+release+'": [\n')
+                    data.append('            {\n')
+                    data.append('              "repository": "'+repository+'",\n')
+                    data.append('              "version": "'+version[pkg][issue][repository]+'",\n')
                     if status[pkg][issue][repository] == 0:
                         # 1 = vulnerable, 2 = undetermined
-                        data.append('        status: resolved\n')
+                        data.append('              "status": "resolved",\n')
                     else:
-                        data.append('        status: open\n')
-                    data.append('        urgency: '+urgency[pkg][issue][repository]+'\n')
+                        data.append('              "status": "open",\n')
+                    data.append('              "urgency": "'+urgency[pkg][issue][repository]+'",\n')
                     if nodsa[pkg][issue].has_key(repository):
-                        data.append('        nodsa: '+nodsa[pkg][issue][repository]+'\n')
+                        data.append('              "nodsa": "'+nodsa[pkg][issue][repository]+'",\n')
+                    data.append('            },\n')
+                    data.append('          ], \n')
+                data.append('        ],\n')
+                data.append('      },\n')
+            data.append('    ],\n')
+        data.append('}\n')
 
         return BinaryResult(''.join(data),'application/octet-stream')
 




More information about the Secure-testing-commits mailing list