diff --git a/.gitignore b/.gitignore index 99b980705742a67dfce3a948cf16006d4fa3e628..19357e968f9a880c9c582f176d91697186b1d749 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ static/rest_framework/ static/debug_toolbar/ doc/build/* doc/build/.buildinfo +settings/settings_secret.py diff --git a/doc/source/lvem.rst b/doc/source/lvem.rst index 319b77bd4b704e2a30bcae8674f90590bba89ea8..b381e6c8dbf398b56aca58096b41e0d76fb525ce 100644 --- a/doc/source/lvem.rst +++ b/doc/source/lvem.rst @@ -28,8 +28,8 @@ Scripted access for LV-EM members ============================================ Some processes need to access GraceDB in a *scripted* manner. For example, -an observational group might set up an automated process to listen for GCN -notices for new GW events and download the skymaps for further processing +an observational group might set up an automated process to listen for LIGO/Virgo GCN +notices and then download the skymaps for further processing (see the `tutorial <http://nbviewer.ipython.org/github/lpsinger/ligo-virgo-emfollowup-tutorial/blob/master/ligo-virgo-emfollowup-tutorial.ipynb>`__). As these alerts could come at any time of the day or night, it is not generally possible for the user to go through the usual login sequence. Traditionally, @@ -62,6 +62,7 @@ to make sure that only you can read it). The ``.netrc`` file could look like thi login myself@institution.edu password abc123..... +Place the resulting ``.netrc`` file in your home directory. Once that's done, you should be able to access the GraceDB REST API using any tool that supports basic auth. For example, you can use the GraceDB Python client in much the same @@ -148,8 +149,9 @@ observation record consisting of three separate footprints:: if r.status == 201: # 201 means 'Created' print 'Success!' -For users not familiar with Python, there are several other options available for -uploading observation records: +Note that the start times are always assumed to be in UTC. For users not +familiar with Python, there are several other options available for uploading +observation records: - by using the webform on each event page (scroll down to the 'EM Observations' section and click on 'add observation record'). However, this method requires diff --git a/doc/source/web.rst b/doc/source/web.rst index d49558d32f83538012a4183509ed5e3bc8286c11..66aebafa7bf51da49379189c6ca486c24bae0fde 100644 --- a/doc/source/web.rst +++ b/doc/source/web.rst @@ -21,7 +21,7 @@ each other in various ways: - by GPS time or range - ``gpstime: 999999999`` - ``899999000..999999999`` -- by event creation time +- by event creation time in UTC - ``created: 2009-10-08 .. 2009-12-04 16:00:00`` - ``yesterday .. now`` - by specific graceid or range diff --git a/gracedb/buildVOEvent.py b/gracedb/buildVOEvent.py index c62b04f6d3134d3c0eb11bf6a9933b5e0ed2639c..9e3e3bdbc91eabd83825e429918d53b6605ac921 100755 --- a/gracedb/buildVOEvent.py +++ b/gracedb/buildVOEvent.py @@ -21,7 +21,7 @@ from VOEventLib.VOEvent import Time, TimeInstant # XXX ER2.utils. utils is in project directory. ugh. from utils import gpsToUtc -from datetime import datetime +from django.utils import timezone from django.conf import settings from django.core.urlresolvers import reverse from models import CoincInspiralEvent, MultiBurstEvent @@ -104,7 +104,7 @@ def buildVOEvent(event, serial_number, voevent_type, request=None, skymap_filena a.add_contactName("LIGO Scientific Collaboration and Virgo Collaboration") #a.add_contactEmail("postmaster@ligo.org") w.set_Author(a) - w.set_Date(datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")) + w.set_Date(timezone.now().strftime("%Y-%m-%dT%H:%M:%S")) v.set_Who(w) ############ Why ############################ diff --git a/gracedb/management/commands/create_test_perms_fixtures.py b/gracedb/management/commands/create_test_perms_fixtures.py index 08f6ef28397f44c5c49963730b621c2ce45deb0d..398df14f1c815f73603cd4580e90203c45cafd08 100644 --- a/gracedb/management/commands/create_test_perms_fixtures.py +++ b/gracedb/management/commands/create_test_perms_fixtures.py @@ -1,7 +1,6 @@ import os import json from StringIO import StringIO -from datetime import datetime from gracedb.models import GrbEvent, Tag, Event from gracedb.models import MultiBurstEvent @@ -13,6 +12,8 @@ from django.core.management import call_command from django.core.management.base import NoArgsCommand from django.conf import settings +from django.utils import timezone + #------------------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------------------ # Parameters @@ -143,7 +144,7 @@ def get_user_field_dicts(user_info): user_dict['user_permissions'] = [] user_dict['password'] = 'X' - now = datetime.now().isoformat().split('.')[0] + now = timezone.now().isoformat().split('.')[0] user_dict['last_login'] = now user_dict['date_joined'] = now diff --git a/gracedb/management/commands/make_histograms.py b/gracedb/management/commands/make_histograms.py index 057e6348ec12e56e122a3f5333cc2ca2887a437f..d36307de4797a0b8832553c8eb35605abed20ec1 100644 --- a/gracedb/management/commands/make_histograms.py +++ b/gracedb/management/commands/make_histograms.py @@ -10,8 +10,8 @@ import numpy from gracedb.models import Event, Pipeline import os -from datetime import datetime, timedelta - +from datetime import timedelta +from django.utils import timezone DEST_DIR = settings.LATENCY_REPORT_DEST_DIR MAX_X = settings.LATENCY_MAXIMUM_CHARTED @@ -27,7 +27,7 @@ class Command(NoArgsCommand): def handle_noargs(self, **options): - now = datetime.now() + now = timezone.now() start_day = now - timedelta(1) start_week = now - timedelta(7) @@ -71,7 +71,7 @@ class Command(NoArgsCommand): def writeIndex(notes, fname): - createdDate = str(datetime.now()) + createdDate = str(timezone.now()) maxx = MAX_X table = '<table border="1" bgcolor="white">' diff --git a/gracedb/models.py b/gracedb/models.py index c2343ddf8f12149e7fb13154d1832fdf96da0b60..d328d5761f0c5014d6f6ce572caf1fec3ad03a96 100644 --- a/gracedb/models.py +++ b/gracedb/models.py @@ -26,7 +26,8 @@ import json from utils import posixToGpsTime from django.conf import settings -import pytz, time +import pytz +import calendar from cStringIO import StringIO from hashlib import sha1 @@ -175,7 +176,8 @@ class Event(models.Model): dt = self.created if not dt.tzinfo: dt = SERVER_TZ.localize(dt) - posix_time = time.mktime(dt.timetuple()) + dt = dt.astimezone(pytz.utc) + posix_time = calendar.timegm(dt.timetuple()) gps_time = int(posixToGpsTime(posix_time)) return gps_time - self.gpstime diff --git a/gracedb/nltime.py b/gracedb/nltime.py index b6ce811d085da39bb04f0a51404f52d777da17fe..0cbcc7338d86dce803530caa5f612c5b403c2427 100755 --- a/gracedb/nltime.py +++ b/gracedb/nltime.py @@ -6,6 +6,12 @@ from datetime import datetime, timedelta from pyparsing import * import calendar +from django.utils import timezone +import pytz + +# Note, since the 'now' comes from django.utils.timezone, it will be in UTC. +# We should therefore localize all of the datetime objects generated here to +# UTC. # string conversion parse actions def convertToTimedelta(toks): @@ -25,7 +31,7 @@ def convertToTimedelta(toks): toks["timeOffset"] = td def convertToDay(toks): - now = datetime.now() + now = timezone.now() if "wkdayRef" in toks: todaynum = now.weekday() daynames = [n.lower() for n in calendar.day_name] @@ -34,23 +40,23 @@ def convertToDay(toks): daydiff = (nameddaynum + 7 - todaynum) % 7 else: daydiff = -((todaynum + 7 - nameddaynum) % 7) - toks["absTime"] = datetime(now.year, now.month, now.day)+timedelta(daydiff) + toks["absTime"] = pytz.utc.localize(datetime(now.year, now.month, now.day)+timedelta(daydiff)) else: name = toks.name.lower() toks["absTime"] = { "now" : now, - "today" : datetime(now.year, now.month, now.day), - "yesterday" : datetime(now.year, now.month, now.day)+timedelta(-1), - "tomorrow" : datetime(now.year, now.month, now.day)+timedelta(+1), + "today" : pytz.utc.localize(datetime(now.year, now.month, now.day)), + "yesterday" : pytz.utc.localize(datetime(now.year, now.month, now.day)+timedelta(-1)), + "tomorrow" : pytz.utc.localize(datetime(now.year, now.month, now.day)+timedelta(+1)), }[name] def convertToAbsTime(toks): - now = datetime.now() + now = timezone.now() if "dayRef" in toks: day = toks.dayRef.absTime - day = datetime(day.year, day.month, day.day) + day = pytz.utc.localize(datetime(day.year, day.month, day.day)) else: - day = datetime(now.year, now.month, now.day) + day = pytz.utc.localize(datetime(now.year, now.month, now.day)) if "timeOfDay" in toks: if isinstance(toks.timeOfDay,basestring): timeOfDay = { @@ -78,7 +84,7 @@ def calculateTime(toks): if toks.absTime: absTime = toks.absTime else: - absTime = datetime.now() + absTime = timezone.now() if toks.timeOffset: absTime += toks.timeOffset toks["calculatedTime"] = absTime @@ -181,7 +187,7 @@ if __name__ == "__main__": 2009/12/22 12:13:14""".splitlines() for t in tests: - print t, "(relative to %s)" % datetime.now() + print t, "(relative to %s)" % timezone.now() res = nlTimeExpression.parseString(t) if "calculatedTime" in res: print res.calculatedTime diff --git a/gracedb/query.py b/gracedb/query.py index 5852ad5c845371061004cf8fdd416dfa495cc0be..f5c00fe9ea38c7a5195951e0148c177ce6b9c0d5 100644 --- a/gracedb/query.py +++ b/gracedb/query.py @@ -20,6 +20,7 @@ import datetime import models from django.db.models import Q from django.db.models.query import QuerySet +import pytz from pyparsing import \ Word, nums, Literal, CaselessLiteral, delimitedList, Suppress, QuotedString, \ @@ -64,6 +65,8 @@ gpsQ = gpsQ.setParseAction(maybeRange("gpstime")) # run ids runmap = { + "O1" : (1126623617, 1136649617), # Friday, Sept 18th, 10 AM CDT - Tuesday, Jan 12th, 10:00 AM CST + "ER8" : (1123858817, 1126623617), # Monday, Aug 17th, 10 AM CDT - Friday, Sept 18th, 10 AM CDT "ER7" : (1117400416, 1118329216), # Jun 03 21:00:00 UTC 2015 - Jun 14 15:00:00 UTC 2015 "ER6" : (1102089616, 1102863616), # Dec 08 16:00:00 UTC 2014 - Dec 17 15:00:00 UTC 2014 "ER5" : (1073822416, 1078876816), # Jan 15 12:00:00 UTC 2014 - Mar 15 2014 00:00:00 UTC @@ -168,7 +171,7 @@ nltimeRange = nltime + Suppress("..") + nltime def doTime(tok): x = datetime.datetime(*(map(int, tok))) - return x + return pytz.utc.localize(x) dash = Suppress('-') colon = Suppress(':') diff --git a/gracedb/reports.py b/gracedb/reports.py index effd01e7bcf9ea0ab7009a0ad512a393e4908277..9725cc5e4b6e67d6088d1fc0d1272e70649bd27b 100644 --- a/gracedb/reports.py +++ b/gracedb/reports.py @@ -24,9 +24,10 @@ import matplotlib.pyplot as plot import StringIO import base64 import sys -import time -from datetime import datetime, timedelta +import calendar +from datetime import timedelta from utils import posixToGpsTime +from django.utils import timezone @internal_user_required def histo(request): @@ -76,7 +77,7 @@ def histo(request): def rate_data(): # XXX there is a better way -- should be using group_by or something. # WAAY too many queries (~300) going on here. - now = datetime.now() + now = timezone.now() day = timedelta(1) ts_min = now - 60 * day @@ -149,11 +150,12 @@ def cbc_report(request, format=""): if request.method == "GET": if "query" not in request.GET: # Use default query. LowMass events from the past week. - t_high = datetime.now() + t_high = timezone.now() dt = timedelta(days=7) t_low = t_high - dt - t_high = posixToGpsTime(time.mktime(t_high.timetuple())) - t_low = posixToGpsTime(time.mktime(t_low.timetuple())) + # Now the times are in UTC. So we can't use mktime to get posix time. + t_high = posixToGpsTime(calendar.timegm(t_high.timetuple())) + t_low = posixToGpsTime(calendar.timegm(t_low.timetuple())) query = 'CBC LowMass %d .. %d' % (t_low, t_high) rawquery = query form = SimpleSearchForm({'query': query}) diff --git a/gracedb/templatetags/flash.py b/gracedb/templatetags/flash.py index 4093b2db2268868268434e6031ac7e098b6f229d..f0c827d3bbec716f8b7098d14dd5d6d39e337cb1 100644 --- a/gracedb/templatetags/flash.py +++ b/gracedb/templatetags/flash.py @@ -34,7 +34,8 @@ django.contrib.sessions.middleware.SessionMiddleware from django import template from django.template import resolve_variable, Context -import datetime +from datetime import timedelta +from django.utils import timezone from django.template.loader import render_to_string from django.contrib.sessions.models import Session from django.conf import settings @@ -59,7 +60,7 @@ def session_clear(session): # Save changes to session if(session.session_key): Session.objects.save(session.session_key, session._session, - datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE)) + timezone.now() + timedelta(seconds=settings.SESSION_COOKIE_AGE)) class RunFlashBlockNode(template.Node): diff --git a/gracedb/templatetags/timeutil.py b/gracedb/templatetags/timeutil.py index 3eaee57bdd904bd6b91fb6b972878dee564ffc78..c2c9248c9b8a7acc1158fcbb1afca9f6a5a7b02d 100644 --- a/gracedb/templatetags/timeutil.py +++ b/gracedb/templatetags/timeutil.py @@ -49,17 +49,20 @@ def get_multitime_value(t, label, autoescape, format): dt = t if not dt.tzinfo: dt = SERVER_TZ.localize(dt) - #dt = dt.astimezone(pytz.utc) + # XXX in order for mktime to give correct results, the time must be + # in the server's timezone. + dt = dt.astimezone(SERVER_TZ) posix_time = time.mktime(dt.timetuple()) gps_time = int(posixToGpsTime(posix_time)) elif isinstance(t, int) or isinstance(t, long): gps_time = t dt = gpsToUtc(t) - posix_time = time.mktime(dt.timetuple()) + # Note: must convert to server timezone before calling mktime + posix_time = time.mktime(dt.astimezone(SERVER_TZ).timetuple()) elif isinstance(t, decimal.Decimal): gps_time = float(t) dt = gpsToUtc(t) - posix_time = time.mktime(dt.timetuple()) + posix_time = time.mktime(dt.astimezone(SERVER_TZ).timetuple()) else: return "N/A" return '<time utc="%s" gps="%s" llo="%s" lho="%s" virgo="%s" jsparsable="%s"%s>%s</time>' % \ @@ -147,6 +150,8 @@ def gpsdate_tz(gpstime, label="utc"): def gpstime(dt): if not dt.tzinfo: dt = SERVER_TZ.localize(dt) + # convert to SERVER_TZ if not already + dt = dt.astimezone(SERVER_TZ) posix_time = time.mktime(dt.timetuple()) gps_time = int(posixToGpsTime(posix_time)) return gps_time @@ -160,17 +165,17 @@ def timeSelections(t): dt = t if not dt.tzinfo: dt = SERVER_TZ.localize(dt) - #dt = dt.astimezone(pytz.utc) + dt = dt.astimezone(SERVER_TZ) posix_time = time.mktime(dt.timetuple()) gps_time = int(posixToGpsTime(posix_time)) elif isinstance(t, int) or isinstance(t, long): gps_time = t dt = gpsToUtc(t) - posix_time = time.mktime(dt.timetuple()) + posix_time = time.mktime(dt.astimezone(SERVER_TZ).timetuple()) elif isinstance(t, decimal.Decimal): gps_time = float(t) dt = gpsToUtc(t) - posix_time = time.mktime(dt.timetuple()) + posix_time = time.mktime(dt.astimezone(SERVER_TZ).timetuple()) else: raise ValueError("time must be type int, long or datetime, not '%s'" % type(t)) diff --git a/gracedb/view_logic.py b/gracedb/view_logic.py index 8c6ebfe1d457b1c40f8631e278c7b024743f6aa7..d529096c4a0e7dee6a2de494c204d0cf8b8b7a9b 100644 --- a/gracedb/view_logic.py +++ b/gracedb/view_logic.py @@ -31,6 +31,7 @@ import datetime #import dateutil from dateutil import parser import logging +import pytz def _createEventFromForm(request, form): saved = False @@ -234,9 +235,14 @@ def get_performance_info(): # Now parse the log file dateformat = '%Y-%m-%dT%H:%M:%S' # ISO format. I think. - # Lookback time is 3 days. - dt_now = datetime.datetime.now() + # Lookback time is 3 days. These are in UTC. + dt_now = timezone.now() dt_min = dt_now + datetime.timedelta(days=-3) + + # Convert to local time + SERVER_TZ = pytz.timezone(settings.TIME_ZONE) + dt_now = dt_now.astimezone(SERVER_TZ) + dt_min = dt_min.astimezone(SERVER_TZ) totals_by_status = {} totals_by_method = {} @@ -245,6 +251,8 @@ def get_performance_info(): datestring = line[0:len('YYYY-MM-DDTHH:MM:SS')] # Check the date to see whether it's fresh enough dt = datetime.datetime.strptime(datestring, dateformat) + # Localize so we can compare with aware datetimes + dt = SERVER_TZ.localize(dt) if dt > dt_min: # Get rid of the datestring and the final colon. line = line[len(datestring)+1:] @@ -539,6 +547,8 @@ def create_emobservation(request, event): try: start_time = parser.parse(start_time) + if not start_time.tzinfo: + start_time = pytz.utc.localize(start_time) except: raise ValueError('Could not parse start time list element %d of %s'%(i, startTimeRealList)) diff --git a/gracedb/view_utils.py b/gracedb/view_utils.py index a8ee6d9b013815450864796a54d4551a220be1ef..1b0f0c9b0855f6e241ff7b10b917c0fe9f96e8f9 100644 --- a/gracedb/view_utils.py +++ b/gracedb/view_utils.py @@ -29,8 +29,8 @@ GRACEDB_DATA_DIR = settings.GRACEDB_DATA_DIR import json import pytz -from datetime import datetime -from time import mktime +import time +import calendar SERVER_TZ = pytz.timezone(settings.TIME_ZONE) def timeToUTC(dt): @@ -483,12 +483,13 @@ def skymapViewerEMObservationToDict(emo, request=None): for t in startTimeList: time_count += 1 # timetuple throws away the microsecond for some reason - avg_time_s += mktime(t.timetuple()) + float(t.microsecond)/1e6 + # Note: the datetimes in the startTimeList are in UTC. + avg_time_s += calendar.timegm(t.timetuple()) + float(t.microsecond)/1e6 if time_count > 0: avg_time_s /= time_count - avg_time = datetime.fromtimestamp(avg_time_s) + avg_time = time.gmtime(avg_time_s) avg_time_string = avg_time.strftime("%a %b %d %H:%M:%S UTC %Y") return { diff --git a/gracedb/views.py b/gracedb/views.py index 641e227755492b0b97446bedb383af626a56d8ee..71a07c4e2d8eee12efc68e1a309d678a91846bd1 100644 --- a/gracedb/views.py +++ b/gracedb/views.py @@ -571,22 +571,35 @@ def oldsearch(request): else: objects = Event.objects.all() + # XXX Note, the uid field doesn't exist anymore. I'm not sure why this + # stuff is in here. (Branson) +# if start: +# if start[0] != 'G': +# # XXX This is the deprecated uid stuff. Take it out when uid is gone. +# objects = objects.filter(uid__gte=start) +# objects = objects.filter(uid__startswith="0") +# else: +# objects = objects.filter(id__gte=int(start[1:])) +# objects = objects.filter(uid="") +# if end: +# if end[0] != 'G': +# # XXX This is the deprecated uid stuff. Take it out when uid is gone. +# objects = objects.filter(uid__lte=end) +# objects = objects.filter(uid__startswith="0") +# else: +# objects = objects.filter(id__lte=int(end[1:])) +# objects = objects.filter(uid="") + if start: - if start[0] != 'G': - # XXX This is the deprecated uid stuff. Take it out when uid is gone. - objects = objects.filter(uid__gte=start) - objects = objects.filter(uid__startswith="0") - else: + if start[0] in 'GEHMT': objects = objects.filter(id__gte=int(start[1:])) - objects = objects.filter(uid="") - if end: - if end[0] != 'G': - # XXX This is the deprecated uid stuff. Take it out when uid is gone. - objects = objects.filter(uid__lte=end) - objects = objects.filter(uid__startswith="0") else: + return HttpResponseBadRequest("Invalid GraceID") + if end: + if end[0] in 'GEHMT': objects = objects.filter(id__lte=int(end[1:])) - objects = objects.filter(uid="") + else: + return HttpResponseBadRequest("Invalid GraceID") if start and end: textQuery.append("gid: %s..%s" % (start, end)) diff --git a/ligoauth/middleware/auth.py b/ligoauth/middleware/auth.py index 47c524a2e40ee47e180b3e007bafd37b4946ef19..dcfe60a607a3344532cfd1c2a4661d50e4786802 100644 --- a/ligoauth/middleware/auth.py +++ b/ligoauth/middleware/auth.py @@ -14,7 +14,7 @@ from django.http import HttpResponse, HttpResponseForbidden proxyPattern = re.compile(r'^(.*?)(/CN=\d+)*$') -from datetime import datetime +from django.utils import timezone from base64 import b64decode import json @@ -153,7 +153,7 @@ class LigoAuthMiddleware: # actually use 'date_joined' for it's intended purpose. # check: is now greater than date_joined + time_delta? if user: - if datetime.now() > user.date_joined + settings.PASSWORD_EXPIRATION_TIME: + if timezone.now() > user.date_joined + settings.PASSWORD_EXPIRATION_TIME: msg = "Your password has expired. Please log in and request another." return HttpResponseForbidden(json.dumps({'error': msg})) diff --git a/settings/branson.py b/settings/branson.py deleted file mode 100644 index f4ec64cd130e87e44aed555f06c1349a2bdcaefb..0000000000000000000000000000000000000000 --- a/settings/branson.py +++ /dev/null @@ -1,247 +0,0 @@ -CONFIG_NAME = "Branson" - -DEBUG = True -TEMPLATE_DEBUG = DEBUG -DEBUG_TOOLBAR_PATCH_SETTINGS = False - -DATABASES = { - 'default' : { - 'NAME' : 'gracedb', - 'ENGINE' : 'django.db.backends.mysql', - 'USER' : 'branson', - 'PASSWORD' : 'thinglet', - 'OPTIONS' : { - 'init_command' : 'SET storage_engine=MYISAM', - }, - } -} - -CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': '127.0.0.1:11211', - - }, - # this cache backend will be used by django-debug-panel - 'debug-panel': { - 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache', - 'LOCATION': '/tmp/debug-panel-cache', - 'OPTIONS': { - 'MAX_ENTRIES': 200 - } - }, -} - -#MEDIA_URL = "/branson-static/" -STATIC_URL = "/branson-static/" -STATIC_ROOT = "/home/branson/gracedbdev/static/" - -BOWER_URL = "/bower-static/" -BOWER_ROOT = "/home/branson/bower_components/" - -#GRACEDB_DATA_DIR = "/home/branson/fake_data" -GRACEDB_DATA_DIR = "/home/branson/new_fake_data" - -EMAIL_HOST = 'localhost' - -ALERT_EMAIL_FROM = "Dev Alert <root@moe.phys.uwm.edu>" -#ALERT_EMAIL_TO = [ -# "Branson Stephens <branson@gravity.phys.uwm.edu>", -# ] -#ALERT_EMAIL_BCC = ["branson@gravity.phys.uwm.edu"] -# -#ALERT_TEST_EMAIL_FROM = "Dev Test Alert <root@moe.phys.uwm.edu>" -#ALERT_TEST_EMAIL_TO = [ -# "Branson Stephens <branson@gravity.phys.uwm.edu>", -# ] -ALERT_EMAIL_TO = [] -ALERT_EMAIL_BCC = [] -ALERT_TEST_EMAIL_FROM = "Dev Test Alert <root@moe.phys.uwm.edu>" -ALERT_TEST_EMAIL_TO = [] -ALERT_XMPP_SERVERS = ["lvalert-test.cgca.uwm.edu",] -LVALERT_SEND_EXECUTABLE = '/home/branson/djangoenv/bin/lvalert_send' - -USE_LVALERT_OVERSEER = True - -# For each lvalert server, a separate instance of the lvalert_overseer -# must be running and listening on a distinct port. -LVALERT_OVERSEER_PORTS = { - 'lvalert-test.cgca.uwm.edu': 8001, -} - -EMBB_MAIL_ADDRESS = 'branson@moe.phys.uwm.edu' -EMBB_SMTP_SERVER = 'localhost' -EMBB_MAIL_ADMINS = ['branson@gravity.phys.uwm.edu',] -EMBB_IGNORE_ADDRESSES = ['Mailer-Daemon@moe.phys.uwm.edu',] - -# Don't sent out non-test XMPP alerts on dev box! -XMPP_ALERT_CHANNELS = [ - 'test_omega', - 'test_mbtaonline', - 'test_cwb', - 'test_lowmass', - ] - -# Latency histograms. Where they go and max latency to bin. -LATENCY_REPORT_DEST_DIR = "/home/branson/new_fake_data/latency" -LATENCY_REPORT_WEB_PAGE_FILE_PATH = LATENCY_REPORT_DEST_DIR + "/latency.inc" - -# Uptime reporting -UPTIME_REPORT_DIR = "/home/branson/new_fake_data/uptime" - -# Rate file location -RATE_INFO_FILE = "/home/branson/new_fake_data/rate_info.json" - -TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. - "/home/branson/gracedbdev/templates", -) - -MIDDLEWARE_CLASSES = [ - 'middleware.accept.AcceptMiddleware', - 'middleware.cli.CliExceptionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'ligoauth.middleware.auth.LigoAuthMiddleware', - 'middleware.performance.PerformanceMiddleware', - #'debug_toolbar.middleware.DebugToolbarMiddleware', - #'debug_panel.middleware.DebugPanelMiddleware', - #'middleware.profiling.ProfileMiddleware', -] - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.admin', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.staticfiles', - 'gracedb', - 'userprofile', - 'ligoauth', - 'rest_framework', - 'guardian', - #'debug_toolbar', - #'debug_panel', -) - -INTERNAL_IPS = ( - '129.89.57.83', -) - -CONTROL_ROOM_IPS = { - 'H1': '206.196.186.148', - 'L1': '129.2.92.124', -# 'L1': '129.89.57.83', -} - -# Settings for Logging. -import logging - -LOG_ROOT = '/home/branson/logs' -LOG_FILE_SIZE = 1024*1024 # 1 MB -LOG_FILE_BAK_CT = 3 -LOG_FORMAT = 'verbose' -LOG_LEVEL = 'DEBUG' - -# Filter objects to separate out each level of alert. -# Otherwise the log files for each level would contain the -# output for each higher level. -class debugOnlyFilter(logging.Filter): - def filter(self,record): - if record.levelname=='DEBUG': - return 1 - return 0 -class infoOnlyFilter(logging.Filter): - def filter(self,record): - if record.levelname=='INFO': - return 1 - return 0 -class debugPlusInfo(logging.Filter): - def filter(self,record): - if record.levelname=='INFO' or record.levelname=='DEBUG': - return 1 - return 0 -class warningOnlyFilter(logging.Filter): - def filter(self,record): - if record.levelname=='WARNING': - return 1 - return 0 -class errorOnlyFilter(logging.Filter): - def filter(self,record): - if record.levelname=='ERROR': - return 1 - return 0 - -# Note that mode for log files is 'a' (append) by default -# The 'level' specifier on the handle is optional, and we -# don't need it since we're using custom filters. -LOGGING = { - 'version': 1, - 'disable_existing_loggers' : True, - 'formatters': { - 'simple': { - 'format': '%(levelname)s %(message)s', - }, - 'verbose': { - 'format': '%(asctime)s: %(name)s: %(message)s', - 'datefmt': '%Y-%m-%d %H:%M:%S', - }, - }, - 'handlers': { - 'null': { - 'level':'DEBUG', - 'class':'django.utils.log.NullHandler', - }, - 'debug_file': { - 'class': 'logging.handlers.RotatingFileHandler', - 'formatter': LOG_FORMAT, - 'filename': '%s/gracedb_debug.log' % LOG_ROOT, - 'maxBytes': LOG_FILE_SIZE, - 'backupCount': LOG_FILE_BAK_CT, - }, - 'performance_file': { - 'class': 'logging.FileHandler', - 'formatter': 'simple', - 'filename': '%s/gracedb_performance.log' % LOG_ROOT, - }, - 'mail_admins': { - 'level': 'ERROR', - 'class': 'django.utils.log.AdminEmailHandler' - } - }, - 'loggers': { - 'django': { - 'handlers': ['null'], - 'propagate': True, - 'level': 'INFO', - }, - 'django.request': { - 'handlers': ['mail_admins'], - 'level': 'ERROR', - 'propagate': False, - }, - 'gracedb': { - 'handlers': ['debug_file'], - 'propagate': True, - 'level': LOG_LEVEL, - }, - 'ligoauth': { - 'handlers': ['debug_file'], - 'propagate': True, - 'level': LOG_LEVEL, - }, - 'middleware': { - 'handlers': ['performance_file'], - 'propagate': True, - 'level': 'INFO', - }, - 'userprofile': { - 'handlers': ['debug_file'], - 'propagate': True, - 'level': LOG_LEVEL, - }, - }, -} diff --git a/settings/default.py b/settings/default.py index 682e82a438027d3f7a1b87f802f853870312f446..4897d5177e639d0985169300c53222417cebf7db 100644 --- a/settings/default.py +++ b/settings/default.py @@ -1,3 +1,6 @@ +from settings_secret import * + +USE_TZ = True # Suitable for production ALLOWED_HOSTS = ['*'] @@ -114,7 +117,7 @@ DATABASES = { 'NAME' : 'gracedb', 'ENGINE' : 'django.db.backends.mysql', 'USER' : 'gracedb', - 'PASSWORD' : 'thinglet', + 'PASSWORD' : DEFAULT_DB_PASSWORD, 'OPTIONS' : { 'init_command': 'SET storage_engine=MyISAM', }, @@ -238,7 +241,7 @@ USE_I18N = False ADMIN_MEDIA_PREFIX = '/media/' # Make this unique, and don't share it with anybody. -SECRET_KEY = '$$&hl%^_4&s0k7sbdr8ll_^gkz-j8oab0tz$t^^b-%$!83d(av' +SECRET_KEY = DEFAULT_SECRET_KEY # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( diff --git a/settings/test.py b/settings/test.py index 2912d30d4d02d6c99859fb0569365bf1b2cc0f66..ce099efc7847137ac524a600a0fd1118f4117000 100644 --- a/settings/test.py +++ b/settings/test.py @@ -1,3 +1,5 @@ +from settings_secret import * + CONFIG_NAME = "Test" DEBUG = True @@ -9,7 +11,7 @@ DATABASES = { 'NAME' : 'gracedb', 'ENGINE' : 'django.db.backends.mysql', 'USER' : 'gracedb', - 'PASSWORD' : 'thinglet', + 'PASSWORD' : TEST_DB_PASSWORD, 'OPTIONS' : { 'init_command' : 'SET storage_engine=MYISAM', }, diff --git a/templates/gracedb/emo_form_frag.html b/templates/gracedb/emo_form_frag.html index 5ef3309b54ce679fc0bc7f6d65d082a98a91b66e..d24281301e85bed94d75457512cdcec3f159b783 100644 --- a/templates/gracedb/emo_form_frag.html +++ b/templates/gracedb/emo_form_frag.html @@ -24,6 +24,7 @@ return true; <tr><td><a href=# onclick="alert('Group with which the LSC has signed a trust agreement, hereby providing data under its trust (required).'); return false;"> Which MOU Group provides this report?</a></td> <td><select name="group"> +<option value=""></option> {% for g in groups %} <option value="{{ g }}">{{ g }}</option> {% endfor %} </select> </td> </tr> @@ -40,7 +41,7 @@ RAwidth (decimal degrees)</a></td> <td><input type="text" name="raWidthLi <tr><td><a href=# onclick="alert('RAWidth and DecWidth specify the size of a a rectangle that is aligned equatorially. Thus the edge of the box is distant from the center by half of the width.');return false;"> Decwidth (decimal degrees)</a></td> <td><input type="text" name="decWidthList" value=""/></td></tr> -<tr><td><a href=# onclick="alert('The time at the beginning of a time interval during which the observation was taken. Or list of times. ISO 8601');return false;"> +<tr><td><a href=# onclick="alert('The time at the beginning of a time interval during which the observation was taken. Or list of times. UTC in ISO 8601 format.');return false;"> StartTime</a></td> <td><input type="text" name="startTimeList" value="" size=80/></td> </tr> diff --git a/templates/gracedb/event_detail.html b/templates/gracedb/event_detail.html index cb3d9b731b17a7254abb57c637dbffdc1cf7f2c4..e7be69ef45503a5cc367634b293bff0413eb25a2 100644 --- a/templates/gracedb/event_detail.html +++ b/templates/gracedb/event_detail.html @@ -10,7 +10,7 @@ <!-- <script charset="utf-8" src="{{STATIC_URL}}js/labeltips.js" type=text/javascript"></script> --> <link rel="stylesheet" href="{{STATIC_URL}}css/labeltips.css"> <script src="{{BOWER_URL}}moment/moment.js"></script> -<script src="{{BOWER_URL}}moment-timezone/moment-timezone-with-data-2010-2020.min.js"></script> +<script src="{{BOWER_URL}}moment-timezone/builds/moment-timezone-with-data.min.js"></script> <script src="{{BOWER_URL}}dojo/dojo.js" data-dojo-config="async: true"></script> <!-- Styles for dgrid --> <!-- <link rel="stylesheet" href="{{BOWER_URL}}dgrid/css/dgrid.css" /> --> diff --git a/templates/gracedb/event_detail_script.js b/templates/gracedb/event_detail_script.js index f24bf3e29c0781e10aaa5164d7a8b18f951c4411..dd09fbd9cf2884f66862be098e581cfbe40a1c11 100644 --- a/templates/gracedb/event_detail_script.js +++ b/templates/gracedb/event_detail_script.js @@ -606,10 +606,6 @@ require([ return is_skymap; }; - skymap_stems.forEach( function(stem) { - console.log("Got skymap stem: " + stem); - }); - // If there are any blessed tags here, we'll do TitlePanes if (our_blessed_tags.length > 0) { // define our columns for the topical digest panes diff --git a/templates/gracedb/query_help_frag.html b/templates/gracedb/query_help_frag.html index 756ffc37ffad7645a6cb983cc792db3b616121f7..e4ef40965a5af7627b6c46a4dc7d342967199e6f 100644 --- a/templates/gracedb/query_help_frag.html +++ b/templates/gracedb/query_help_frag.html @@ -24,7 +24,7 @@ <h4>By Creation Time</h4> Creation time may be indicated by an exact time or a range. Date/times are - in the format <code>2009-10-20 13:00:00</code>. If the time is omitted, it + in the format <code>2009-10-20 13:00:00</code> (must be UTC). If the time is omitted, it is assumed to be <code>00:00:00</code>. Dates may also consist of certain variants of English-like phrases. The <code>created:</code> keyword is (generally) optional. diff --git a/userprofile/views.py b/userprofile/views.py index fa07e9a16c7b6b61f942fc79940cdaac2c45511c..023a41426af19d7d8b36ea96ddf5d22dfc960e8a 100644 --- a/userprofile/views.py +++ b/userprofile/views.py @@ -15,7 +15,7 @@ from forms import ContactForm, triggerFormFactory from gracedb.permission_utils import internal_user_required, lvem_user_required -from datetime import datetime +from django.utils import timezone from gracedb.query import labelQuery from gracedb.models import Label @@ -38,7 +38,7 @@ def managePassword(request): password = User.objects.make_random_password(length=20) d['password'] = password request.user.set_password(password) - request.user.date_joined = datetime.now() + request.user.date_joined = timezone.now() request.user.save() return render_to_response('profile/manage_password.html', d,