Skip to content
Snippets Groups Projects
Commit 80b7e021 authored by Tanner Prestegard's avatar Tanner Prestegard
Browse files

Merge branch 'reorganization_gunicorn' into 'master'

Repository reorganization and port to gunicorn

See merge request lscsoft/gracedb!7
parents b7cd9dbe a5436fe4
No related branches found
No related tags found
1 merge request!7Repository reorganization and port to gunicorn
Showing
with 253 additions and 4166 deletions
{
"directory" : "../bower_components"
}
*.swp
*~
*.pyc
django-*.wsgi
static-collected
static/admin/
static/rest_framework/
static/debug_toolbar/
static/django_extensions/
static/guardian/
doc/build/*
doc/build/.buildinfo
admin_doc/build/*
admin_doc/build/.buildinfo
settings/secret.py
settings/local.py
config/settings/secret.py
config/settings/local.py
docs/user_docs/build/*
docs/admin_docs/build/*
static_root/*
This diff is collapsed.
import sys
import VOEvent
class VOEventExportClass(VOEvent.VOEvent):
def __init__(self, event, schemaURL):
self.event = event
self.schemaURL = schemaURL
def export(self, outfile, level, namespace_='', name_='VOEvent', namespacedef_=''):
VOEvent.showIndent(outfile, level)
added_stuff = 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n'
added_stuff += 'xmlns:voe="http://www.ivoa.net/xml/VOEvent/v2.0"\n'
added_stuff += 'xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v2.0 %s"\n' % self.schemaURL
outfile.write('<%s%s%s %s' % (namespace_, name_,
namespacedef_ and ' ' + namespacedef_ or '',
added_stuff,
))
# self.event.exportAttributes(outfile, level, [], namespace_)
self.event.exportAttributes(outfile, level, [])
if self.event.hasContent_():
outfile.write('>\n')
# self.event.exportChildren(outfile, level + 1, namespace_='', name_)
self.event.exportChildren(outfile, level + 1, '', name_)
VOEvent.showIndent(outfile, level)
outfile.write('</%s%s>\n' % (namespace_, name_))
else:
outfile.write('/>\n')
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
def stringVOEvent(event, schemaURL = "http://www.ivoa.net/xml/VOEvent/VOEvent-v2.0.xsd"):
'''
Converts a VOEvent to a string suitable for output
'''
v = VOEventExportClass(event, schemaURL)
out = StringIO()
out.write('<?xml version="1.0" ?>\n')
v.export(out, 0, namespace_='voe:')
out.write('\n')
return out.getvalue()
def paramValue(p):
s1 = p.get_value()
s2 = p.get_Value()
if not s2: return s1
if not s1: return s2
if len(s1) > len(s2): return s1
else: return s2
def htmlList(list):
'''
Converts a list of strings to an HTML <ul><li> structure.
'''
s = '<ul>'
for x in list:
s += '<li>' + str(x) + '</li>'
s += '</ul>'
return s
def htmlParam(g, p):
'''
Builds an HTML table row from a Param and its enclosing Group (or None)
'''
s = ''
if g == None:
s += '<td/>'
else:
s += '<td>' + g.get_name() + '</td>'
s += '<td>' + str(p.get_name()) + '</td>'
s += '<td>'
for d in p.get_Description(): s += str(d)
s += '</td>'
s += '<td><b>' + str(paramValue(p)) + '</b></td>'
s += '<td>' + str(p.get_ucd()) + '</td>'
s += '<td>' + str(p.get_unit()) + '</td>'
s += '<td>' + str(p.get_dataType()) + '</td>'
return s
def parse(file):
'''
Parses a file and builds the VOEvent DOM.
'''
doc = VOEvent.parsexml_(file)
rootNode = doc.getroot()
rootTag, rootClass = VOEvent.get_root_tag(rootNode)
v = rootClass.factory()
v.build(rootNode)
return v
def parseString(inString):
'''
Parses a string and builds the VOEvent DOM.
'''
from StringIO import StringIO
doc = VOEvent.parsexml_(StringIO(inString))
rootNode = doc.getroot()
rootTag, rootClass = VOEvent.get_root_tag(rootNode)
rootObj = rootClass.factory()
rootObj.build(rootNode)
return rootObj
def getWhereWhen(v):
'''
Builds a dictionary of the information in the WhereWhen section:
observatory: location of observatory (string);
coord_system: coordinate system ID, for example UTC-FK5-GEO;
time: ISO8601 representation of time, for example 1918-11-11T11:11:11;
timeError: in seconds;
longitude: in degrees, usually right ascension;
latitiude: in degrees, usually declination;
positionalError: positional error in degrees.
'''
wwd = {}
ww = v.get_WhereWhen()
if not ww:
return wwd
w = ww.get_ObsDataLocation()
if not w:
return wwd
ol = w.get_ObservatoryLocation()
if ol:
wwd['observatory'] = ol.get_id()
ol = w.get_ObservationLocation()
if not ol:
return wwd
observation = ol.get_AstroCoords()
if not observation:
return wwd
wwd['coord_system'] = observation.get_coord_system_id()
time = observation.get_Time()
wwd['time'] = time.get_TimeInstant().get_ISOTime()
wwd['timeError'] = time.get_Error()
pos = observation.get_Position2D()
if not pos:
return wwd
wwd['positionalError'] = pos.get_Error2Radius()
v2 = pos.get_Value2()
if not v2:
return wwd
wwd['longitude'] = v2.get_C1()
wwd['latitude'] = v2.get_C2()
return wwd
def makeWhereWhen(wwd):
'''
Expects a dictionary of the information in the WhereWhen section, and makes a
VOEvent.WhereWhen object suitable for set_WhereWhen().
observatory: location of observatory (string);
coord_system: coordinate system ID, for example UTC-FK5-GEO;
time: ISO8601 representation of time, for example 1918-11-11T11:11:11;
timeError: in seconds;
longitude: in degrees, usually right ascension;
latitiude: in degrees, usually declination;
positionalError: positional error in degrees.
'''
if not wwd.has_key('observatory'): wwd['observatory'] = 'unknown'
if not wwd.has_key('coord_system'): wwd['coord_system'] = 'UTC-FK5-GEO'
if not wwd.has_key('timeError'): wwd['timeError'] = 0.0
if not wwd.has_key('positionalError'): wwd['positionalError'] = 0.0
if not wwd.has_key('time'):
print "Cannot make WhereWhen without time"
return None
if not wwd.has_key('longitude'):
print "Cannot make WhereWhen without longitude"
return None
if not wwd.has_key('latitude'):
print "Cannot make WhereWhen without latitude"
return None
ac = VOEvent.AstroCoords(coord_system_id=wwd['coord_system'])
ac.set_Time(
VOEvent.Time(
TimeInstant = VOEvent.TimeInstant(wwd['time'])))
ac.set_Position2D(
VOEvent.Position2D(
Value2 = VOEvent.Value2(wwd['longitude'], wwd['latitude']),
Error2Radius = wwd['positionalError']))
acs = VOEvent.AstroCoordSystem(id=wwd['coord_system'])
onl = VOEvent.ObservationLocation(acs, ac)
oyl = VOEvent.ObservatoryLocation(id=wwd['observatory'])
odl = VOEvent.ObsDataLocation(oyl, onl)
ww = VOEvent.WhereWhen()
ww.set_ObsDataLocation(odl)
return ww
def getParamNames(v):
'''
Takes a VOEvent and produces a list of pairs of group name and param name.
For a bare param, the group name is the empty string.
'''
list = []
w = v.get_What()
if not w: return list
for p in v.get_What().get_Param():
list.append(('', p.get_name()))
for g in v.get_What().get_Group():
for p in v.get_What().get_Param():
list.append((g.get_name(), p.get_name()))
return list
def findParam(event, groupName, paramName):
'''
Finds a Param in a given VOEvent that has the specified groupName
and paramName. If it is a bare param, the group name is the empty string.
'''
w = event.get_What()
if not w:
print "No <What> section in the event!"
return None
if groupName == '':
for p in event.get_What().get_Param():
if p.get_name() == paramName:
return p
else:
for g in event.get_What().get_Group():
if g.get_name() == groupName:
for p in event.get_What().get_Param():
if p.get_name() == paramName:
return p
print 'Cannot find param named %s/%s' % (groupName, paramName)
return None
######## utilityTable ########################
class utilityTable(VOEvent.Table):
'''
Class to represent a simple Table from VOEvent
'''
def __init__(self, table):
self.table = table
self.colNames = []
self.default = []
col = 0
for f in table.get_Field():
if f.get_name():
self.colNames.append(f.get_name())
type = f.get_dataType()
if type == 'float': self.default.append(0.0)
elif type == 'int': self.default.append(0)
else: self.default.append('')
def getTable(self):
return self.table
def blankTable(self, nrows):
'''
From a table template, replaces the Data section with nrows of empty TR and TD
'''
data = VOEvent.Data()
ncol = len(self.colNames)
for i in range(nrows):
tr = VOEvent.TR()
for col in range(ncol):
tr.add_TD(self.default[col])
data.add_TR(tr)
self.table.set_Data(data)
def getByCols(self):
'''
Returns a dictionary of column vectors that represent the table.
The key for the dict is the Field name for that column.
'''
d = self.table.get_Data()
nrow = len(d.get_TR())
ncol = len(self.colNames)
# we will build a matrix nrow*ncol and fill in the values as they
# come in, with col varying fastest. The return is a dictionary,
# arranged by column name, each with a vector of
# properly typed values.
data = []
for col in range(ncol):
data.append([self.default[col]]*nrow)
row = 0
for tr in d.get_TR():
col = 0
for td in tr.get_TD():
data[col][row] = td
col += 1
row += 1
dict = {}
col = 0
for colName in self.colNames:
dict[colName] = data[col]
col += 1
return dict
def setValue(self, name, irow, value, out=sys.stdout):
'''
Copies a single value into a cell of the table.
The column is identified by its name, and the row by an index 0,1,2...
'''
if name in self.colNames:
icol = self.colNames.index(name)
else:
print>>out, "setTable: Unknown column name %s. Known list is %s" % (name, str(self.colNames))
return False
d = self.table.get_Data()
ncols = len(self.colNames)
nrows = len(d.get_TR())
if nrows <= irow:
print>>out, "setTable: not enough rows -- you want %d, table has %d. Use blankTable to allocate the table." % (irow+1, nrows)
return False
tr = d.get_TR()[irow]
row = tr.get_TD()
row[icol] = value
tr.set_TD(row)
def toString(self):
'''
Makes a crude string representation of a utilityTable
'''
s = ' '
for name in self.colNames:
s += '%9s|' % name[:9]
s += '\n\n'
d = self.table.get_Data()
for tr in d.get_TR():
for td in tr.get_TD():
s += '%10s' % str(td)[:10]
s += '\n'
return s
{
"name": "gracedb",
"dependencies": {
"dgrid": "0.4.0",
"dijit": "1.10.4",
"dojox": "1.10.4",
"jquery": "3.2.1",
"moment-timezone": "0.5.0",
"moment": "2.11.1"
}
}
File moved
# To run this manually (not via systemd):
# gunicorn --config config/gunicorn_config.py config.wsgi:application
# (assuming that you are in the base directory of the GraceDB server code repo)
import os
from os.path import abspath, dirname, join
import sys
import multiprocessing
# Parameters
GUNICORN_PORT = 8000
LOG_DIR = abspath(join(dirname(__file__), "..", "..", "logs"))
# Gunicorn configuration ------------------------------------------------------
# Bind to localhost on specified port
bind = "127.0.0.1:{port}".format(port=GUNICORN_PORT)
# Number of workers = 2*CPU + 1 (recommendation from Gunicorn documentation)
workers = multiprocessing.cpu_count()*2 + 1
# Worker type
worker_type = 'sync'
# Max requests settings - a worker restarts after handling this many
# requests. May be useful if we have memory leak problems.
# The jitter is drawn from a uniform distribution:
# randint(0, max_requests_jitter)
#max_requests = 0
#max_requests_jitter = 0
# Access log
accesslog = join(LOG_DIR, "gunicorn_access.log")
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
# Error log
errorlog = join(LOG_DIR, "gunicorn_error.log")
loglevel = 'debug'
capture_output = True
#forwarded_allow_ips = '127.0.0.1'
#proxy_allow_ips = '127.0.0.1'
File moved
import os, time, socket, logging
import os, time, logging
from os.path import abspath, dirname, join
from datetime import datetime, timedelta
from cloghandler import ConcurrentRotatingFileHandler
from utils import posixToGpsTime
from core.time_utils import posixToGpsTime
# Get local settings:
# SERVER_HOSTNAME, SERVER_FQDN, IS_PRODUCTION_SERVER, ADMINS, GRACEDB_PATHS
......@@ -11,6 +12,11 @@ from .local import *
# TWILIO_AUTH_TOKEN, TWIML_BIN
from .secret import *
# Set up path to root of project
BASE_DIR = abspath(join(dirname(__file__), "..", ".."))
CONFIG_ROOT = join(BASE_DIR, "config")
PROJECT_ROOT = join(BASE_DIR, "gracedb")
# Miscellaneous settings ------------------------------------------------------
# Debug mode is off by default
DEBUG = False
......@@ -27,6 +33,10 @@ TEST_RUNNER = 'django.test.runner.DiscoverRunner'
# BrokenLinkEmailsMiddleware is enabled
MANAGERS = ADMINS
# Use forwarded host header for Apache -> Gunicorn reverse proxy configuration
USE_X_FORWARDED_HOST = True
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Base URL for TwiML bins (for Twilio phone/text alerts)
TWIML_BASE_URL = 'https://handler.twilio.com/twiml/'
......@@ -37,7 +47,7 @@ USE_TZ = True
# hostname.ligo.org. Security measure for preventing cache poisoning and
# stopping requests submitted with a fake HTTP Host header.
ALLOWED_HOSTS = ['localhost', '127.0.0.1', SERVER_FQDN,
'{0}.ligo.org'.format(socket.gethostname())]
'{0}.ligo.org'.format(SERVER_HOSTNAME)]
# LVAlert and LVAlert Overseer settings ---------------------------------------
# Switches which control whether alerts are sent out
......@@ -55,8 +65,8 @@ LVALERT_OVERSEER_PORTS = {
}
# Path to lvalert_send executable, for failover in case
# LVAlert Overseer is not running.
LVALERT_SEND_EXECUTABLE = os.path.join(GRACEDB_PATHS["virtualenv"],
os.path.join("bin", "lvalert_send"))
LVALERT_SEND_EXECUTABLE = join(GRACEDB_PATHS["virtualenv"], "bin",
"lvalert_send")
# Email settings --------------------------------------------------------------
EMAIL_HOST = 'localhost'
......@@ -142,26 +152,26 @@ SKYALERT_SUBMITTERS = ['Patrick Brady', 'Brian Moe']
# Latency histograms. Where they go and max latency to bin.
LATENCY_REPORT_DEST_DIR = GRACEDB_PATHS["latency"]
LATENCY_MAXIMUM_CHARTED = 1800
LATENCY_REPORT_WEB_PAGE_FILE_PATH = os.path.join(LATENCY_REPORT_DEST_DIR,
LATENCY_REPORT_WEB_PAGE_FILE_PATH = join(LATENCY_REPORT_DEST_DIR,
"latency.inc")
# Uptime reporting
UPTIME_REPORT_DIR = GRACEDB_PATHS["uptime"]
# Rate file location
RATE_INFO_FILE = os.path.join(GRACEDB_PATHS["data"], "rate_info.json")
RATE_INFO_FILE = join(GRACEDB_PATHS["data"], "rate_info.json")
# URL prefix for serving report information (usually plots and tables)
# This is aliased to GRACEDB_PATHS["latency"] in the Apache virtualhost
# configuration. If you change this, you will need to change that.
REPORT_INFO_URL_PREFIX = "{sep}report_info{sep}".format(sep=os.path.sep)
REPORT_INFO_URL_PREFIX = "/report_info/"
# Directory for CBC IFAR Reports
REPORT_IFAR_IMAGE_DIR = GRACEDB_PATHS["latency"]
# Stuff for the new rates plot
BINNED_COUNT_PIPELINES = ['gstlal', 'MBTAOnline', 'CWB', 'LIB', 'gstlal-spiir']
BINNED_COUNT_FILE = os.path.join(GRACEDB_PATHS["data"], "binned_counts.json")
BINNED_COUNT_FILE = join(GRACEDB_PATHS["data"], "binned_counts.json")
# Defaults for RSS feed
FEED_MAX_RESULTS = 50
......@@ -208,7 +218,7 @@ TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(GRACEDB_PATHS["code"], "templates"),
join(PROJECT_ROOT, "templates"),
],
'APP_DIRS': True,
'OPTIONS': {
......@@ -221,8 +231,8 @@ TEMPLATES = [
'django.template.context_processors.static',
# Extra additions
'django.template.context_processors.request',
'gracedb.middleware.auth.LigoAuthContext',
'middleware.debug.LigoDebugContext',
'events.context_processors.LigoAuthContext',
'core.context_processors.LigoDebugContext',
'ligoauth.context_processors.shib_login_url',
],
},
......@@ -232,7 +242,7 @@ TEMPLATES = [
# List of authentication backends to use when attempting to authenticate
# a user. Will be used in this order
AUTHENTICATION_BACKENDS = (
# 'gracedb.middleware.auth.LigoAuthBackend',
# 'events.middleware.auth.LigoAuthBackend',
'ligoauth.middleware.auth.LigoX509Backend',
'ligoauth.middleware.auth.LigoShibBackend',
'ligoauth.middleware.auth.LigoBasicBackend',
......@@ -245,9 +255,9 @@ AUTHENTICATION_BACKENDS = (
# List of middleware classes to use.
MIDDLEWARE = [
'middleware.performance.PerformanceMiddleware',
'middleware.accept.AcceptMiddleware',
'middleware.cli.CliExceptionMiddleware',
'events.middleware.PerformanceMiddleware',
'core.middleware.accept.AcceptMiddleware',
'core.middleware.cli.CliExceptionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
......@@ -256,7 +266,7 @@ MIDDLEWARE = [
]
# Path to root URLconf
ROOT_URLCONF = 'urls'
ROOT_URLCONF = '{module}.urls'.format(module=os.path.basename(CONFIG_ROOT))
# List of string designating all applications which are enabled.
INSTALLED_APPS = [
......@@ -267,7 +277,7 @@ INSTALLED_APPS = [
# 'django.contrib.sites',
'django.contrib.staticfiles',
'maintenance_mode',
'gracedb',
'events',
'userprofile',
'ligoauth',
'rest_framework',
......@@ -284,25 +294,26 @@ REST_FRAMEWORK = {
},
}
# Location of packages installed by bower
BOWER_DIR = join(BASE_DIR, "..", "bower_components")
# Location of static components, CSS, JS, etc.
STATIC_ROOT = os.path.join(GRACEDB_PATHS["code"], "static") + os.path.sep
STATIC_URL = "{sep}gracedb-static{sep}".format(sep=os.path.sep)
STATIC_ROOT = join(BASE_DIR, "static_root")
STATIC_URL = "/static/"
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
]
STATICFILES_DIRS = []
# Location of Bower packages.
BOWER_URL = "{sep}bower-static{sep}".format(sep=os.path.sep)
BOWER_ROOT = os.path.join(GRACEDB_PATHS["home"], "bower_components") + \
os.path.sep
STATICFILES_DIRS = [
join(PROJECT_ROOT, "static"),
BOWER_DIR,
]
# Added in order to perform data migrations on the auth app
# Added in order to perform data migrations on the auth and guardian apps
MIGRATION_MODULES = {
'auth' : 'migrations.auth',
'guardian' : 'migrations.guardian',
'auth': 'migrations.auth',
'guardian': 'migrations.guardian',
}
# Forces test database to be created with syncdb rather than via
......@@ -399,8 +410,7 @@ LOGGING = {
'debug_file': {
'class': 'logging.handlers.ConcurrentRotatingFileHandler',
'formatter': LOG_FORMAT,
'filename': os.path.join(GRACEDB_PATHS["logs"],
"gracedb_debug.log"),
'filename': join(GRACEDB_PATHS["logs"], "gracedb_debug.log"),
'maxBytes': (20*1024*1024),
'backupCount': LOG_FILE_BAK_CT,
'level': 'DEBUG',
......@@ -408,8 +418,7 @@ LOGGING = {
'error_file': {
'class': 'logging.handlers.ConcurrentRotatingFileHandler',
'formatter': LOG_FORMAT,
'filename': os.path.join(GRACEDB_PATHS["logs"],
"gracedb_error.log"),
'filename': join(GRACEDB_PATHS["logs"], "gracedb_error.log"),
'maxBytes': LOG_FILE_SIZE,
'backupCount': LOG_FILE_BAK_CT,
'level': 'ERROR',
......@@ -419,8 +428,7 @@ LOGGING = {
'maxBytes': 1024*1024,
'backupCount': 1,
'formatter': 'simple',
'filename': os.path.join(GRACEDB_PATHS["logs"],
"gracedb_performance.log"),
'filename': join(GRACEDB_PATHS["logs"], "gracedb_performance.log"),
},
'mail_admins': {
'level': 'ERROR',
......@@ -433,25 +441,30 @@ LOGGING = {
'propagate': True,
'level': 'INFO',
},
'gracedb': {
'core': {
'handlers': ['debug_file','error_file'],
'propagate': True,
'level': LOG_LEVEL,
},
'ligoauth': {
'events': {
'handlers': ['debug_file','error_file'],
'propagate': True,
'level': LOG_LEVEL,
},
'userprofile': {
'performance': {
'handlers': ['performance_file'],
'propagate': True,
'level': 'INFO',
},
'ligoauth': {
'handlers': ['debug_file','error_file'],
'propagate': True,
'level': LOG_LEVEL,
},
'middleware': {
'handlers': ['performance_file'],
'userprofile': {
'handlers': ['debug_file','error_file'],
'propagate': True,
'level': 'INFO',
'level': LOG_LEVEL,
},
'django.request': {
'handlers': ['mail_admins'],
......
File moved
# Settings for a test GraceDB instance.
# Starts with base.py settings and overrides or adds to them.
from .base import *
import socket
CONFIG_NAME = "TEST"
......@@ -12,9 +13,10 @@ DEBUG = True
EMBB_MAIL_ADDRESS = 'gracedb@{fqdn}'.format(fqdn=SERVER_FQDN)
# Add middleware
debug_middleware = 'debug_toolbar.middleware.DebugToolbarMiddleware'
MIDDLEWARE += [
'debug_toolbar.middleware.DebugToolbarMiddleware',
#'middleware.profiling.ProfileMiddleware',
debug_middleware,
#'core.middleware.profiling.ProfileMiddleware',
]
# Add to installed apps
......@@ -23,10 +25,22 @@ INSTALLED_APPS += [
'django_extensions',
]
# Tuple of IPs which are marked as internal, useful for debugging
# Changed to a list in Django 1.9+
# Add testserver to ALLOWED_HOSTS
ALLOWED_HOSTS += ['testserver']
# Add XForwardedFor middleware directly before debug_toolbar middleware
# if debug_toolbar is enabled and DEBUG is True.
if DEBUG and debug_middleware in MIDDLEWARE:
MIDDLEWARE.insert(MIDDLEWARE.index(debug_middleware),
'core.middleware.proxy.XForwardedForMiddleware')
# Tuple of IPs which are marked as internal, useful for debugging.
# Tanner (5 Dec. 2017): DON'T CHANGE THIS! Django Debug Toolbar exposes
# some headers which we want to keep hidden. So to be safe, we only allow
# it to be used through this server. You need to configure a SOCKS proxy
# on your local machine to use DJDT (see admin docs).
INTERNAL_IPS = [
'129.89.57.200',
socket.gethostbyname(socket.gethostname()),
]
# Aliases for django-extensions shell_plus
......
......@@ -7,36 +7,39 @@ from django.conf import settings
from django.contrib import admin
admin.autodiscover()
from gracedb.feeds import EventFeed, feedview
# Import feeds
from events.feeds import EventFeed, feedview
# After Django 1.10, have to import views directly, rather
# than just using a string
import gracedb.views
import gracedb.reports
import events.views
import events.reports
feeds = {
'latest' : EventFeed
}
urlpatterns = [
url(r'^$', gracedb.views.index, name="home"),
url(r'^navbar_only$', gracedb.views.navbar_only, name="navbar-only"),
url(r'^SPInfo', gracedb.views.spinfo, name="spinfo"),
url(r'^SPPrivacy', gracedb.views.spprivacy, name="spprivacy"),
url(r'^DiscoveryService', gracedb.views.discovery, name="discovery"),
url(r'^events/', include('gracedb.urls')),
url(r'^api/', include('gracedb.urls_rest', app_name="api", namespace="x509")),
url(r'^apiweb/', include('gracedb.urls_rest', app_name="api", namespace="shib")),
url(r'^apibasic/', include('gracedb.urls_rest', app_name="api", namespace="basic")),
url(r'^$', events.views.index, name="home"),
url(r'^navbar_only$', events.views.navbar_only, name="navbar-only"),
url(r'^SPInfo', events.views.spinfo, name="spinfo"),
url(r'^SPPrivacy', events.views.spprivacy, name="spprivacy"),
url(r'^DiscoveryService', events.views.discovery, name="discovery"),
url(r'^events/', include('events.urls')),
url(r'^apiweb/', include('events.api.urls', app_name="api",
namespace="shib")),
url(r'^api/', include('events.api.urls', app_name="api", namespace="x509")),
url(r'^apibasic/', include('events.api.urls', app_name="api",
namespace="basic")),
url(r'^options/', include('userprofile.urls')),
url(r'^feeds/(?P<url>.*)/$', EventFeed()),
url(r'^feeds/$', feedview, name="feeds"),
url(r'^performance/$', gracedb.views.performance, name="performance"),
url(r'^reports/$', gracedb.reports.histo, name="reports"),
url(r'^performance/$', events.views.performance, name="performance"),
url(r'^reports/$', events.reports.histo, name="reports"),
url(r'^reports/cbc_report/(?P<format>(json|flex))?$',
gracedb.reports.cbc_report, name="cbc_report"),
url(r'^latest', gracedb.views.latest, name="latest"),
events.reports.cbc_report, name="cbc_report"),
url(r'^latest', events.views.latest, name="latest"),
#(r'^reports/(?P<path>.+)$', 'django.views.static.serve',
# {'document_root': settings.LATENCY_REPORT_DEST_DIR}),
......@@ -47,9 +50,6 @@ urlpatterns = [
url(r'^admin/', admin.site.urls),
# For development only. And only for old Django versions (like 1.2)
#(r'^gracedb-static/(?P<path>.*)$', 'django.views.static.serve',
# {'document_root': settings.MEDIA_ROOT}),
]
if settings.DEBUG:
......
import os
import sys
from os.path import abspath, dirname, join
# Parameters
SETTINGS_MODULE = 'config.settings'
PROJECT_ROOT_NAME = 'gracedb'
VENV_NAME = 'djangoenv'
# Set DJANGO_SETTINGS_MODULE environment variable if not already set
os.environ.setdefault('DJANGO_SETTINGS_MODULE', SETTINGS_MODULE)
# Set up base dir of repository
BASE_DIR = abspath(join(dirname(__file__), ".."))
# Add the source code directory and project root
sys.path.append(BASE_DIR)
sys.path.append(join(BASE_DIR, PROJECT_ROOT_NAME))
# Activate the virtual environment
VIRTUALENV_ACTIVATOR = abspath(join(BASE_DIR, '..', VENV_NAME, 'bin',
'activate_this.py'))
execfile(VIRTUALENV_ACTIVATOR, dict(__file__=VIRTUALENV_ACTIVATOR))
# Matplotlib config directory
os.environ['MPLCONFIGDIR'] = '/tmp/'
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment