Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: sitescripts/notifications/parser.py

Issue 29321041: Issue 2707 - Support start/end notification parameters (Closed)
Patch Set: Change date format Created June 24, 2015, 7:52 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sitescripts/notifications/test/parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/notifications/parser.py
===================================================================
--- a/sitescripts/notifications/parser.py
+++ b/sitescripts/notifications/parser.py
@@ -16,6 +16,7 @@
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
import codecs
+import datetime
import os
import re
import subprocess
@@ -87,6 +88,8 @@
current["targets"] = [target]
elif key == "sample" and is_variant:
current["sample"] = float(value)
+ elif key in ["start", "end"]:
+ current[key] = datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M")
else:
raise Exception("Unknown parameter '%s' in file '%s'" % (key, name))
@@ -118,6 +121,11 @@
notification = _parse_notification(data, name)
if "inactive" in notification:
continue
+ current_time = datetime.datetime.now()
+ if "start" in notification and current_time < notification["start"]:
+ continue
+ if "end" in notification and current_time > notification["end"]:
+ continue
notifications.append(notification)
except:
traceback.print_exc()
« no previous file with comments | « no previous file | sitescripts/notifications/test/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld