1818from ietf .sync import iana
1919from ietf .sync import rfceditor
2020from ietf .sync .rfceditor import MIN_QUEUE_RESULTS , parse_queue , update_drafts_from_queue
21- from ietf .sync .rfcindex import create_rfc_txt_index , create_rfc_xml_index
21+ from ietf .sync .rfcindex import (
22+ create_bcp_txt_index ,
23+ create_fyi_txt_index ,
24+ create_rfc_txt_index ,
25+ create_rfc_xml_index ,
26+ create_std_txt_index ,
27+ )
2228from ietf .sync .utils import build_from_file_content , load_rfcs_into_blobdb , rsync_helper
2329from ietf .utils import log
2430from ietf .utils .timezone import date_today
2733@shared_task
2834def rfc_editor_index_update_task (full_index = False ):
2935 """Update metadata from the RFC index
30-
36+
3137 Default is to examine only changes in the past 365 days. Call with full_index=True to update
3238 the full RFC index.
33-
39+
3440 According to comments on the original script, a year's worth took about 20s on production as of
3541 August 2022
36-
42+
3743 The original rfc-editor-index-update script had a long-disabled provision for running the
3844 rebuild_reference_relations scripts after the update. That has not been brought over
3945 at all because it should be implemented as its own task if it is needed.
@@ -51,7 +57,7 @@ def rfc_editor_index_update_task(full_index=False):
5157 timeout = 30 , # seconds
5258 )
5359 except requests .Timeout as exc :
54- log .log (f' GET request timed out retrieving RFC editor index: { exc } ' )
60+ log .log (f" GET request timed out retrieving RFC editor index: { exc } " )
5561 return # failed
5662 rfc_index_xml = response .text
5763 index_data = rfceditor .parse_index (io .StringIO (rfc_index_xml ))
@@ -61,9 +67,9 @@ def rfc_editor_index_update_task(full_index=False):
6167 timeout = 30 , # seconds
6268 )
6369 except requests .Timeout as exc :
64- log .log (f' GET request timed out retrieving RFC editor errata: { exc } ' )
70+ log .log (f" GET request timed out retrieving RFC editor errata: { exc } " )
6571 return # failed
66- errata_data = response .json ()
72+ errata_data = response .json ()
6773 if len (index_data ) < rfceditor .MIN_INDEX_RESULTS :
6874 log .log ("Not enough index entries, only %s" % len (index_data ))
6975 return # failed
@@ -96,15 +102,15 @@ def rfc_editor_queue_updates_task():
96102 drafts , warnings = parse_queue (io .StringIO (response .text ))
97103 for w in warnings :
98104 log .log (f"Warning: { w } " )
99-
105+
100106 if len (drafts ) < MIN_QUEUE_RESULTS :
101107 log .log ("Not enough results, only %s" % len (drafts ))
102108 return # failed
103-
109+
104110 changed , warnings = update_drafts_from_queue (drafts )
105111 for w in warnings :
106112 log .log (f"Warning: { w } " )
107-
113+
108114 for c in changed :
109115 log .log (f"Updated { c } " )
110116
@@ -120,9 +126,11 @@ def iana_changes_update_task():
120126 MAX_INTERVAL_ACCEPTED_BY_IANA = datetime .timedelta (hours = 23 )
121127
122128 start = (
123- timezone .now ()
124- - datetime .timedelta (hours = 23 )
125- + datetime .timedelta (seconds = CLOCK_SKEW_COMPENSATION ,)
129+ timezone .now ()
130+ - datetime .timedelta (hours = 23 )
131+ + datetime .timedelta (
132+ seconds = CLOCK_SKEW_COMPENSATION ,
133+ )
126134 )
127135 end = start + datetime .timedelta (hours = 23 )
128136
@@ -133,7 +141,9 @@ def iana_changes_update_task():
133141 # requests if necessary
134142
135143 text = iana .fetch_changes_json (
136- settings .IANA_SYNC_CHANGES_URL , t , min (end , t + MAX_INTERVAL_ACCEPTED_BY_IANA )
144+ settings .IANA_SYNC_CHANGES_URL ,
145+ t ,
146+ min (end , t + MAX_INTERVAL_ACCEPTED_BY_IANA ),
137147 )
138148 log .log (f"Retrieved the JSON: { text } " )
139149
@@ -159,9 +169,9 @@ def iana_protocols_update_task():
159169 # "this needs to be the date where this tool is first deployed" in the original
160170 # iana-protocols-updates script)"
161171 rfc_must_published_later_than = datetime .datetime (
162- 2012 ,
163- 11 ,
164- 26 ,
172+ 2012 ,
173+ 11 ,
174+ 26 ,
165175 tzinfo = datetime .UTC ,
166176 )
167177
@@ -171,17 +181,17 @@ def iana_protocols_update_task():
171181 timeout = 30 ,
172182 )
173183 except requests .Timeout as exc :
174- log .log (f' GET request timed out retrieving IANA protocols page: { exc } ' )
184+ log .log (f" GET request timed out retrieving IANA protocols page: { exc } " )
175185 return
176186
177187 rfc_numbers = iana .parse_protocol_page (response .text )
178188
179189 def batched (l , n ):
180190 """Split list l up in batches of max size n.
181-
191+
182192 For Python 3.12 or later, replace this with itertools.batched()
183193 """
184- return (l [i : i + n ] for i in range (0 , len (l ), n ))
194+ return (l [i : i + n ] for i in range (0 , len (l ), n ))
185195
186196 for batch in batched (rfc_numbers , 100 ):
187197 updated = iana .update_rfc_log_from_protocol_page (
@@ -192,6 +202,7 @@ def batched(l, n):
192202 for d in updated :
193203 log .log ("Added history entry for %s" % d .display_name ())
194204
205+
195206@shared_task
196207def fix_subseries_docevents_task ():
197208 """Repairs DocEvents related to bugs around removing docs from subseries
@@ -233,6 +244,7 @@ def fix_subseries_docevents_task():
233244 time = obsoleting_time
234245 )
235246
247+
236248@shared_task
237249def rsync_rfcs_from_rfceditor_task (rfc_numbers : list [int ]):
238250 log .log (f"Rsyncing rfcs from rfc-editor: { rfc_numbers } " )
@@ -277,6 +289,32 @@ def load_rfcs_into_blobdb_task(start: int, end: int):
277289
278290@shared_task
279291def create_rfc_index_task ():
280- create_rfc_txt_index ()
281- create_rfc_xml_index ()
292+ try :
293+ create_rfc_txt_index ()
294+ except Exception as e :
295+ log .log (f"Error: failure in creating rfc-index.txt. { e } " )
296+ pass
282297
298+ try :
299+ create_rfc_xml_index ()
300+ except Exception as e :
301+ log .log (f"Error: failure in creating rfc-index.xml. { e } " )
302+ pass
303+
304+ try :
305+ create_bcp_txt_index ()
306+ except Exception as e :
307+ log .log (f"Error: failure in creating bcp-index.txt. { e } " )
308+ pass
309+
310+ try :
311+ create_std_txt_index ()
312+ except Exception as e :
313+ log .log (f"Error: failure in creating std-index.txt. { e } " )
314+ pass
315+
316+ try :
317+ create_fyi_txt_index ()
318+ except Exception as e :
319+ log .log (f"Error: failure in creating fyi-index.txt. { e } " )
320+ pass
0 commit comments