Skip to content

Commit

Permalink
Merge pull request #59 from CybercentreCanada/NSRL_quarterly_updates
Browse files Browse the repository at this point in the history
Patch in quarterly dates for fetching from NSRL
  • Loading branch information
cccs-rs authored Jan 31, 2025
2 parents 405dd63 + 9187df3 commit e0421e7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion safelist/update_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import csv
import datetime
import math
import os
import re
import sqlite3
Expand Down Expand Up @@ -282,9 +284,17 @@ def do_source_update(self, service: Service) -> None:

self.push_status("UPDATING", "Starting..")
source = source_obj.as_primitives()
uri: str = source["uri"]
default_classification = source.get("default_classification", classification.UNRESTRICTED)

if "${QUARTERLY}" in source["uri"]:
# Special case for quarterly updates from NSRL
y, m = datetime.now().strftime("%Y.%m").split(".")
d = 1
m = "%02d" % (math.floor(float(int(m) / 3)) * 3)
source["uri"] = source["uri"].replace("${QUARTERLY}", f"{y}.{m}.{d}")
source["pattern"] = source["pattern"].replace("${QUARTERLY}", f"{y}.{m}.{d}")

uri: str = source["uri"]
try:
self.push_status("UPDATING", "Pulling..")
output = None
Expand Down

0 comments on commit e0421e7

Please sign in to comment.