Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michael William Coughlin
GraceDB Server
Commits
affef57b
Commit
affef57b
authored
15 years ago
by
Brian Moe
Browse files
Options
Downloads
Patches
Plain Diff
Email alerts when events are created.
parent
67ca90d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
django-dev.wsgi
+13
-0
13 additions, 0 deletions
django-dev.wsgi
django.wsgi
+0
-1
0 additions, 1 deletion
django.wsgi
gracedb/alert.py
+98
-77
98 additions, 77 deletions
gracedb/alert.py
settings.py
+3
-0
3 additions, 0 deletions
settings.py
settings_dev.py
+95
-0
95 additions, 0 deletions
settings_dev.py
with
209 additions
and
78 deletions
django-dev.wsgi
0 → 100644
+
13
−
0
View file @
affef57b
import os
import sys
sys.path.append('/home/lars/django')
sys.path.append('/opt/lscsoft/glue/lib64/python2.4/site-packages')
sys.path.append('/opt/lscsoft/glue/lib/python2.4/site-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = 'gracedb.settings_dev'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
This diff is collapsed.
Click to expand it.
django.wsgi
+
0
−
1
View file @
affef57b
...
@@ -7,7 +7,6 @@ sys.path.append('/opt/lscsoft/glue/lib64/python2.4/site-packages')
...
@@ -7,7 +7,6 @@ sys.path.append('/opt/lscsoft/glue/lib64/python2.4/site-packages')
sys.path.append('/opt/lscsoft/glue/lib/python2.4/site-packages')
sys.path.append('/opt/lscsoft/glue/lib/python2.4/site-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = 'gracedb.settings'
os.environ['DJANGO_SETTINGS_MODULE'] = 'gracedb.settings'
#os.environ['PYTHON_EGG_CACHE'] = '/tmp/egg-trash'
import django.core.handlers.wsgi
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
application = django.core.handlers.wsgi.WSGIHandler()
...
...
This diff is collapsed.
Click to expand it.
gracedb/alert.py
+
98
−
77
View file @
affef57b
...
@@ -3,7 +3,28 @@ import sys
...
@@ -3,7 +3,28 @@ import sys
import
time
import
time
from
subprocess
import
Popen
,
PIPE
,
STDOUT
from
subprocess
import
Popen
,
PIPE
,
STDOUT
from
django.core.mail
import
send_mail
from
django.conf
import
settings
def
issueAlert
(
event
,
location
):
def
issueAlert
(
event
,
location
):
issueXMPPAlert
(
event
,
location
)
issueEmailAlert
(
event
,
location
)
def
issueEmailAlert
(
event
,
location
):
subject
=
"
[gracedb] New %s event. ID: %s
"
%
(
event
.
get_analysisType_display
(),
event
.
uid
)
message
=
"""
New Event
%s / %s
UID: %s
Location: %s
TWiki Page: %s
"""
message
%=
(
event
.
group
.
name
,
event
.
get_analysisType_display
(),
event
.
uid
,
location
,
event
.
wikiurl
())
fromaddress
=
settings
.
ALERT_EMAIL_FROM
to
=
settings
.
ALERT_EMAIL_TO
send_mail
(
subject
,
message
,
fromaddress
,
to
)
def
issueXMPPAlert
(
event
,
location
):
# XXX awful!
# XXX awful!
if
event
.
analysisType
!=
'
MBTA
'
:
if
event
.
analysisType
!=
'
MBTA
'
:
return
return
...
@@ -34,83 +55,83 @@ def issueAlert(event, location):
...
@@ -34,83 +55,83 @@ def issueAlert(event, location):
else
:
else
:
break
break
def
issueAlertX
(
event
,
location
):
#
def issueAlertX(event, location):
username
=
"
gracedb
"
#
username = "gracedb"
server
=
"
lvalert.phys.uwm.edu
"
#
server = "lvalert.phys.uwm.edu"
resource
=
"
sender
"
#
resource = "sender"
password
=
"
w4k3upal1ve
"
#
password = "w4k3upal1ve"
node
=
"
cbc_mbta_online
"
#
node = "cbc_mbta_online"
voevent
=
createPayload
(
event
.
uid
,
location
)
#
voevent = createPayload(event.uid, location)
#
myjid
=
JID
(
username
+
"
@
"
+
server
+
"
/
"
+
resource
)
#
myjid=JID(username+"@"+server+"/"+resource)
recpt
=
JID
(
"
pubsub.
"
+
server
)
#
recpt=JID("pubsub."+server)
#
s
=
MyClient
(
jid
=
myjid
,
password
=
password
,
recpt
=
recpt
)
#
s=MyClient(jid=myjid, password=password, recpt=recpt)
s
.
connect
()
#
s.connect()
s
.
send_myevent
(
voevent
,
node
)
#
s.send_myevent(voevent, node)
s
.
loop
(
1
)
#
s.loop(1)
#
def
createPayload
(
uid
,
filename
):
#
def createPayload (uid, filename):
template
=
"""
<?xml version=
'
1.0
'
encoding=
'
utf-8
'
?>
#
template = """<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE LIGO_LW SYSTEM
"
http://ldas-sw.ligo.caltech.edu/doc/ligolwAPI/html/ligolw_dtd.txt
"
>
#
<!DOCTYPE LIGO_LW SYSTEM "http://ldas-sw.ligo.caltech.edu/doc/ligolwAPI/html/ligolw_dtd.txt">
<LIGO_LW>
#
<LIGO_LW>
<Table Name=
"
LVAlert:table
"
>
#
<Table Name="LVAlert:table">
<Column Type=
"
lstring
"
Name=
"
LVAlert:uid
"
/>
#
<Column Type="lstring" Name="LVAlert:uid"/>
<Column Type=
"
lstring
"
Name=
"
LVAlert:file
"
/>
#
<Column Type="lstring" Name="LVAlert:file"/>
<Stream Name=
"
LVAlert:table
"
Type=
"
Local
"
Delimiter=
"
,
"
>
#
<Stream Name="LVAlert:table" Type="Local" Delimiter=",">
"
%(uid)s
"
,
"
%(filename)s
"
#
"%(uid)s","%(filename)s"
</Stream>
#
</Stream>
</Table>
#
</Table>
</LIGO_LW>
#
</LIGO_LW>
"""
#
"""
return
template
%
{
'
uid
'
:
uid
,
'
filename
'
:
filename
}
#
return template % { 'uid': uid, 'filename': filename }
#
# pubsub import must come first because it overloads part of the
#
# pubsub import must come first because it overloads part of the
# StanzaProcessor class
#
# StanzaProcessor class
from
glue.lvalert
import
pubsub
#
from glue.lvalert import pubsub
#
from
pyxmpp.all
import
JID
,
TLSSettings
#
from pyxmpp.all import JID, TLSSettings
from
pyxmpp.jabber.all
import
Client
#
from pyxmpp.jabber.all import Client
#
#
class
MyClient
(
Client
):
#
class MyClient(Client):
def
__init__
(
self
,
jid
,
password
,
recpt
):
#
def __init__(self, jid, password, recpt):
# if bare JID is provided add a resource -- it is required
#
# if bare JID is provided add a resource -- it is required
if
not
jid
.
resource
:
#
if not jid.resource:
jid
=
JID
(
jid
.
node
,
jid
.
domain
,
"
sender
"
)
#
jid=JID(jid.node, jid.domain, "sender")
self
.
myrecpt
=
recpt
#
self.myrecpt = recpt
#
# we require a TLS connection
#
# we require a TLS connection
t
=
TLSSettings
(
require
=
True
,
verify_peer
=
False
)
#
t=TLSSettings(require=True,verify_peer=False)
#
# setup client with provided connection information
#
# setup client with provided connection information
# and identity data
#
# and identity data
Client
.
__init__
(
self
,
jid
,
password
,
\
#
Client.__init__(self, jid, password, \
auth_methods
=
[
"
sasl:GSSAPI
"
,
"
sasl:PLAIN
"
],
tls_settings
=
t
)
#
auth_methods=["sasl:GSSAPI","sasl:PLAIN"], tls_settings=t)
#
def
stream_state_changed
(
self
,
state
,
arg
):
#
def stream_state_changed(self,state,arg):
"""
This one is called when the state of stream connecting the component
#
"""This one is called when the state of stream connecting the component
to a server changes. This will usually be used to let the user
#
to a server changes. This will usually be used to let the user
know what is going on.
"""
#
know what is going on."""
pass
#
pass
#
def
session_started
(
self
):
#
def session_started(self):
self
.
stream
.
set_response_handlers
(
self
.
pspl
,
\
#
self.stream.set_response_handlers(self.pspl, \
self
.
pspl
.
generic_result
,
self
.
pspl
.
create_error
,
\
#
self.pspl.generic_result,self.pspl.create_error,\
self
.
pspl
.
create_timeout
)
#
self.pspl.create_timeout)
self
.
stream
.
send
(
self
.
pspl
)
#
self.stream.send(self.pspl)
#
def
idle
(
self
):
#
def idle(self):
if
self
.
stream
and
self
.
session_established
:
#
if self.stream and self.session_established:
self
.
disconnect
()
#
self.disconnect()
time
.
sleep
(
2
)
#
time.sleep(2)
#
def
post_disconnect
(
self
):
#
def post_disconnect(self):
raise
Disconnected
#
raise Disconnected
#
def
send_myevent
(
self
,
voevent
,
node
):
#
def send_myevent(self, voevent, node):
self
.
pspl
=
pubsub
.
PubSub
(
from_jid
=
self
.
jid
,
to_jid
=
self
.
myrecpt
,
stream
=
self
,
stanza_type
=
"
get
"
)
#
self.pspl=pubsub.PubSub(from_jid = self.jid, to_jid = self.myrecpt, stream = self, stanza_type="get")
self
.
pspl
.
publish
(
voevent
,
node
)
#
self.pspl.publish(voevent,node)
# vi: sts=4 et sw=4
# vi: sts=4 et sw=4
This diff is collapsed.
Click to expand it.
settings.py
+
3
−
0
View file @
affef57b
...
@@ -9,6 +9,9 @@ ADMINS = (
...
@@ -9,6 +9,9 @@ ADMINS = (
MANAGERS
=
ADMINS
MANAGERS
=
ADMINS
ALERT_EMAIL_FROM
=
"
bmoe@uwm.edu
"
ALERT_EMAIL_TO
=
[
"
bmoe@gravity.phys.uwm.edu
"
]
DATABASE_ENGINE
=
'
mysql
'
DATABASE_ENGINE
=
'
mysql
'
DATABASE_NAME
=
'
gracedb
'
DATABASE_NAME
=
'
gracedb
'
DATABASE_USER
=
'
gracedb
'
DATABASE_USER
=
'
gracedb
'
...
...
This diff is collapsed.
Click to expand it.
settings_dev.py
0 → 100755
+
95
−
0
View file @
affef57b
# Django settings for gracedb project.
DEBUG
=
True
TEMPLATE_DEBUG
=
DEBUG
ADMINS
=
(
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS
=
ADMINS
ALERT_EMAIL_FROM
=
"
bmoe@uwm.edu
"
ALERT_EMAIL_TO
=
[
"
bmoe@gravity.phys.uwm.edu
"
,
"
bmoe@uwm.edu
"
]
DATABASE_ENGINE
=
'
mysql
'
DATABASE_NAME
=
'
gracedb
'
DATABASE_USER
=
'
gracedb
'
DATABASE_PASSWORD
=
'
redrum4x
'
DATABASE_HOST
=
''
# Set to empty string for localhost.
DATABASE_PORT
=
''
# Set to empty string for default.
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE
=
'
America/Chicago
'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE
=
'
en-us
'
SITE_ID
=
2
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N
=
True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT
=
''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL
=
''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
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
'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS
=
(
'
django.template.loaders.filesystem.load_template_source
'
,
'
django.template.loaders.app_directories.load_template_source
'
,
# 'django.template.loaders.eggs.load_template_source',
)
TEMPLATE_CONTEXT_PROCESSORS
=
(
"
django.core.context_processors.auth
"
,
"
django.core.context_processors.debug
"
,
"
django.core.context_processors.i18n
"
,
"
django.core.context_processors.media
"
,
"
lars.middleware.auth.LigoAuthContext
"
,
)
MIDDLEWARE_CLASSES
=
(
'
gracedb.middleware.accept.AcceptMiddleware
'
,
'
gracedb.middleware.auth.LigoAuthMiddleware
'
,
'
django.middleware.common.CommonMiddleware
'
,
'
django.contrib.sessions.middleware.SessionMiddleware
'
,
'
django.contrib.auth.middleware.AuthenticationMiddleware
'
,
)
ROOT_URLCONF
=
'
gracedb.urls
'
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/lars/django/gracedb/templates
"
,
)
INSTALLED_APPS
=
(
'
django.contrib.auth
'
,
'
django.contrib.admin
'
,
'
django.contrib.contenttypes
'
,
'
django.contrib.sessions
'
,
'
django.contrib.sites
'
,
'
gracedb.gracedb
'
,
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment