Merge ubuntu-sponsoring:subdir-for-jsons into ubuntu-sponsoring:master

Proposed by Sebastien Bacher
Status: Merged
Merged at revision: 2eaec701ab7959b7f1c2fe0748ed78c9d78b172d
Proposed branch: ubuntu-sponsoring:subdir-for-jsons
Merge into: ubuntu-sponsoring:master
Diff against target: 22 lines (+9/-2)
1 file modified
sponsors-page.py (+9/-2)
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+399912@code.launchpad.net

Commit message

Write the json reports in a subdir

It's easier to list them this way. Keep the old location for compatibility

Description of the change

Currently browsing http://reqorts.qa.ubuntu.com/reports/sponsoring/ loads the index.html. I'm working on creating some sponsoring KPI and it would be nice to be able to iterate over the records from a directory rather than coding the list of filename.

The reports are also still written to the old location for compatibility reasons in case other scripts or service rely on the current url.

I've deleted the remove use since opening the file in 'w' mode is enough to replace the content

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

This looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/sponsors-page.py b/sponsors-page.py
index e2d76a6..6c06437 100755
--- a/sponsors-page.py
+++ b/sponsors-page.py
@@ -568,8 +568,15 @@ def generate_page(items, devs, packages, other_teams=[], team=None):
568 json_items = []568 json_items = []
569 for item in items:569 for item in items:
570 json_items += [item.prepare_json()]570 json_items += [item.prepare_json()]
571 if os.path.exists(json_filename):571
572 os.remove(json_filename)572 # create a subdir for the json reports
573 if not os.path.exists("jsons"):
574 os.mkdir("jsons")
575 f = open(os.path.join("jsons", json_filename), "w")
576 f.write(json.dumps(json_items))
577 f.close()
578
579 # still write to the old location for compatibility
573 f = open(json_filename, "w")580 f = open(json_filename, "w")
574 f.write(json.dumps(json_items))581 f.write(json.dumps(json_items))
575 f.close()582 f.close()

Subscribers

People subscribed via source and target branches

to all changes: