From 0f69f87a565338989a27a82eb1ab051bd773f2e4 Mon Sep 17 00:00:00 2001 From: Ole Laursen Date: Fri, 21 Jun 2013 16:48:05 +0000 Subject: [PATCH] Skip IANA - Review Needed and Version Changed - Review Needed changes from IANA as it turns out that the Datatracker is the authoritative source on these states. Also improve logging so that the raw JSON from IANA is dumped, the parsed JSON on imported changes is dumped and we write to syslog before starting a sync script in the notification view. - Legacy-Id: 5800 --- ietf/bin/iana-changes-updates | 4 +++- ietf/sync/iana.py | 7 +++++++ ietf/sync/tests.py | 6 ++++++ ietf/sync/views.py | 3 +++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ietf/bin/iana-changes-updates b/ietf/bin/iana-changes-updates index c0f2a1b6f..67361f90f 100755 --- a/ietf/bin/iana-changes-updates +++ b/ietf/bin/iana-changes-updates @@ -55,11 +55,13 @@ while t < end: # requests if necessary text = fetch_changes_json(settings.IANA_SYNC_CHANGES_URL, t, min(end, t + MAX_INTERVAL_ACCEPTED_BY_IANA)) + syslog.syslog("Retrieved the JSON: %s" % text) + changes = parse_changes_json(text) added_events, warnings = update_history_with_changes(changes, send_email=options.send_email) for e in added_events: - syslog.syslog("Added event for %s %s: %s" % (e.doc_id, e.time, e.desc)) + syslog.syslog("Added event for %s %s: %s (parsed json: %s)" % (e.doc_id, e.time, e.desc, e.json)) for w in warnings: syslog.syslog("WARNING: %s" % w) diff --git a/ietf/sync/iana.py b/ietf/sync/iana.py index 2284a30ad..2d280210f 100644 --- a/ietf/sync/iana.py +++ b/ietf/sync/iana.py @@ -169,6 +169,11 @@ def update_history_with_changes(changes, send_email=True): state = states[kind][c["state"]] state_type = "draft-iana-%s" % kind + if state.slug in ("need-rev", "changed"): + # the Datatracker is the ultimate source of these + # states, so skip them + continue + e = StateDocEvent.objects.filter(type="changed_state", time=timestamp, state_type=state_type, state=state) if not e: @@ -185,6 +190,8 @@ def update_history_with_changes(changes, send_email=True): e = add_state_change_event(doc, system, prev_state, state, timestamp) if e: + # for logging purposes + e.json = c added_events.append(e) if not StateDocEvent.objects.filter(doc=doc, time__gt=timestamp, state_type=state_type): diff --git a/ietf/sync/tests.py b/ietf/sync/tests.py index 385315414..1b066dc8c 100644 --- a/ietf/sync/tests.py +++ b/ietf/sync/tests.py @@ -45,6 +45,12 @@ class IANASyncTestCase(django.test.TestCase): "state": "IANA Not OK", "type": "iana_review", }, + { + "time": "2011-10-09 12:00:02", + "doc": draft.name, + "state": "IANA - Review Needed", # this should be skipped + "type": "iana_review", + }, { "time": "2011-10-09 12:00:00", "doc": draft.name, diff --git a/ietf/sync/views.py b/ietf/sync/views.py index 917216590..d038c0440 100644 --- a/ietf/sync/views.py +++ b/ietf/sync/views.py @@ -78,6 +78,9 @@ def notify(request, org, notification): out, _ = p.communicate() return (p.returncode, out) + import syslog + syslog.syslog("Running sync script from notify view POST") + if notification == "protocols": failed, out = runscript("iana-protocols-updates")