Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
alarm-mail
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs
ds
alarm-mail
Commits
05282ab1
Commit
05282ab1
authored
4 years ago
by
Graziano Scalamera
Browse files
Options
Downloads
Patches
Plain Diff
Add configurable egiga url
parent
d9caa560
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/AlarmMail.py
+49
-46
49 additions, 46 deletions
src/AlarmMail.py
src/AlarmMail.xmi
+7
-3
7 additions, 3 deletions
src/AlarmMail.xmi
with
56 additions
and
49 deletions
src/AlarmMail.py
+
49
−
46
View file @
05282ab1
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# "$Name: $";
# "$Header: /home/cvsadm/cvsroot/fermi/servers/alarmmail/AlarmMail.py,v 1.6 2019-06-20 11:52:19 graziano Exp $";
# ############################################################################
...
...
@@ -178,53 +176,54 @@ class AlarmMail (PyTango.Device_4Impl):
msg_link
=
''
att_conf_str
=
''
values
=
[]
if
params
[
'
values
'
].
startswith
(
'
{
'
):
jsonval
=
json
.
loads
(
params
[
'
values
'
])
for
key
,
value
in
jsonval
.
iteritems
():
values
+=
[
key
+
'
=
'
+
str
(
value
).
replace
(
'"'
,
''
)]
else
:
values
=
params
[
'
values
'
].
split
(
'
,
'
)
for
value
in
values
:
#values[value.split('=',1)[0]] = value.split('=',1)[1]
att
=
value
.
split
(
'
=
'
,
1
)[
0
]
if
len
(
att
)
==
0
:
continue
#print('looping value=' + value + ' len(value.split(''='',1)[0])=')
print
(
'
looping value=
'
+
value
)
#print(len(att))
print
(
'
->
'
+
value
.
split
(
'
=
'
,
1
)[
0
])
word
=
'
([a-zA-Z0-9\+\._\*\#\-\:]+)
'
#ind = r'\[[0-9]+\]);'
ind
=
r
'
\[(.*?)\]
'
try
:
m
=
re
.
compile
(
"
tango://
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
ind
).
match
(
att
)
#match fqdn with ind
if
m
is
not
None
:
att
=
"
tango://
"
+
m
.
groups
()[
0
]
+
"
/
"
+
m
.
groups
()[
1
]
+
"
/
"
+
m
.
groups
()[
2
]
+
"
/
"
+
m
.
groups
()[
3
]
+
"
/
"
+
m
.
groups
()[
4
]
att_conf_id
=
self
.
att_conf_fqdn_Map
[
att
]
else
:
m1
=
re
.
compile
(
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
ind
).
match
(
value
.
split
(
'
=
'
,
1
)[
0
])
#match NOT fqdn with ind
if
m1
is
not
None
:
att
=
m1
.
groups
()[
0
]
+
"
/
"
+
m1
.
groups
()[
1
]
+
"
/
"
+
m1
.
groups
()[
2
]
+
"
/
"
+
m1
.
groups
()[
3
]
att_conf_id
=
self
.
att_conf_Map
[
att
]
if
len
(
egiga_url
)
>
0
:
if
params
[
'
values
'
].
startswith
(
'
{
'
):
jsonval
=
json
.
loads
(
params
[
'
values
'
])
for
key
,
value
in
jsonval
.
iteritems
():
values
+=
[
key
+
'
=
'
+
str
(
value
).
replace
(
'"'
,
''
)]
else
:
values
=
params
[
'
values
'
].
split
(
'
,
'
)
for
value
in
values
:
#values[value.split('=',1)[0]] = value.split('=',1)[1]
att
=
value
.
split
(
'
=
'
,
1
)[
0
]
if
len
(
att
)
==
0
:
continue
#print('looping value=' + value + ' len(value.split(''='',1)[0])=')
print
(
'
looping value=
'
+
value
)
#print(len(att))
print
(
'
->
'
+
value
.
split
(
'
=
'
,
1
)[
0
])
word
=
'
([a-zA-Z0-9\+\._\*\#\-\:]+)
'
#ind = r'\[[0-9]+\]);'
ind
=
r
'
\[(.*?)\]
'
try
:
m
=
re
.
compile
(
"
tango://
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
ind
).
match
(
att
)
#match fqdn with ind
if
m
is
not
None
:
att
=
"
tango://
"
+
m
.
groups
()[
0
]
+
"
/
"
+
m
.
groups
()[
1
]
+
"
/
"
+
m
.
groups
()[
2
]
+
"
/
"
+
m
.
groups
()[
3
]
+
"
/
"
+
m
.
groups
()[
4
]
att_conf_id
=
self
.
att_conf_fqdn_Map
[
att
]
else
:
m2
=
re
.
compile
(
"
tango://
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
).
match
(
att
)
#match fqdn without ind
if
m2
is
not
None
:
att
=
"
tango://
"
+
m2
.
groups
()[
0
]
+
"
/
"
+
m2
.
groups
()[
1
]
+
"
/
"
+
m2
.
groups
()[
2
]
+
"
/
"
+
m2
.
groups
()[
3
]
+
"
/
"
+
m2
.
groups
()[
4
]
att_conf_id
=
self
.
att_conf_fqdn_Map
[
att
]
else
:
#try NOT fqdn without ind
att
=
value
.
split
(
'
=
'
,
1
)[
0
]
m1
=
re
.
compile
(
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
ind
).
match
(
value
.
split
(
'
=
'
,
1
)[
0
])
#match NOT fqdn with ind
if
m1
is
not
None
:
att
=
m1
.
groups
()[
0
]
+
"
/
"
+
m1
.
groups
()[
1
]
+
"
/
"
+
m1
.
groups
()[
2
]
+
"
/
"
+
m1
.
groups
()[
3
]
att_conf_id
=
self
.
att_conf_Map
[
att
]
if
len
(
att_conf_str
)
==
0
:
att_conf_str
=
str
(
att_conf_id
)
+
'
,1,1
'
else
:
att_conf_str
+=
'
;
'
+
str
(
att_conf_id
)
+
'
,1,1
'
else
:
m2
=
re
.
compile
(
"
tango://
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
+
"
/
"
+
word
).
match
(
att
)
#match fqdn without ind
if
m2
is
not
None
:
att
=
"
tango://
"
+
m2
.
groups
()[
0
]
+
"
/
"
+
m2
.
groups
()[
1
]
+
"
/
"
+
m2
.
groups
()[
2
]
+
"
/
"
+
m2
.
groups
()[
3
]
+
"
/
"
+
m2
.
groups
()[
4
]
att_conf_id
=
self
.
att_conf_fqdn_Map
[
att
]
else
:
#try NOT fqdn without ind
att
=
value
.
split
(
'
=
'
,
1
)[
0
]
att_conf_id
=
self
.
att_conf_Map
[
att
]
if
len
(
att_conf_str
)
==
0
:
att_conf_str
=
str
(
att_conf_id
)
+
'
,1,1
'
else
:
att_conf_str
+=
'
;
'
+
str
(
att_conf_id
)
+
'
,1,1
'
except
Exception
,
e
:
print
'
Cannot find att_conf_id for
'
,
value
print
e
except
Exception
,
e
:
print
'
Cannot find att_conf_id for
'
,
value
print
e
if
len
(
att_conf_str
)
>
0
:
link
=
'
http://fcsproxy.elettra.trieste.it/docs/egiga2m/egiga2m.html?conf=fermi_hdbpp
&start=
'
+
start_date
+
'
&stop=
'
+
stop_date
+
'
&ts=
'
+
att_conf_str
+
'
&show_error=
'
link
=
egiga_url
+
'
&start=
'
+
start_date
+
'
&stop=
'
+
stop_date
+
'
&ts=
'
+
att_conf_str
+
'
&show_error=
'
msg_link
=
'
<a href=
"'
+
link
+
'"
>
'
+
link
+
'
</a><br>
'
if
len
(
msg_link
)
==
0
:
...
...
@@ -378,10 +377,10 @@ class AlarmMail (PyTango.Device_4Impl):
dtnow
=
dtnow
+
timedelta
(
hours
=
1
)
stop_date
=
dtnow
.
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
start_date
=
dtstart
.
strftime
(
"
%Y-%m-%d %H:%M:%S
"
)
msg_procfs
=
'
http://fcsproxy.elettra.trieste.it/docs/egiga2m/egiga2m.html?conf=fermi_hdbpp
&start=
'
+
start_date
+
'
&stop=
'
+
stop_date
+
'
&ts=
'
+
str
(
att_conf_id
)
+
'
,1,1&show_error=
'
msg_procfs
=
egiga_url
+
'
&start=
'
+
start_date
+
'
&stop=
'
+
stop_date
+
'
&ts=
'
+
str
(
att_conf_id
)
+
'
,1,1&show_error=
'
except
Exception
,
e
:
print
'
Cannot find att_conf_id for
'
,
params
[
'
name
'
]
msg_procfs
=
'
http://fcsproxy.elettra.trieste.it/docs/egiga2m/egiga2m.html?conf=fermi_hdbpp
'
msg_procfs
=
egiga_url
msg
=
MIMEText
(
'
<html><head></head><body><p>NEW ALARM DETECTED: <br>Name:
'
+
params
[
'
name
'
]
+
'
<br>Message:
'
+
params
[
'
msg
'
]
+
'
<br>Values:
'
+
params
[
'
values
'
]
+
'
<br>Formula:
'
+
params
[
'
formula
'
]
+
'
<br><br>HDB++ eGiga link:<br><br><a href=
"'
+
msg_procfs
+
'"
>
'
+
msg_procfs
+
'
</a></p></body></html>
'
,
'
html
'
)
msg
[
'
Subject
'
]
=
'
ALARMED
'
+
params
[
'
name
'
]
+
'
-
'
+
params
[
'
msg
'
]
msg
[
'
From
'
]
=
'"'
+
self
.
email_name
+
'"
<
'
+
self
.
email_user
+
'
>
'
...
...
@@ -456,6 +455,10 @@ class AlarmMailClass(PyTango.DeviceClass):
[
PyTango
.
DevString
,
''
,
[]
],
'
egiga_url
'
:
[
PyTango
.
DevString
,
"
eGiga url
"
,
[]
],
}
...
...
This diff is collapsed.
Click to expand it.
src/AlarmMail.xmi
+
7
−
3
View file @
05282ab1
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem
xmi:version=
"2.0"
xmlns:xmi=
"http://www.omg.org/XMI"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:pogoDsl=
"http://www.esrf.fr/tango/pogo/PogoDsl"
>
<classes
name=
"AlarmMail"
pogoRevision=
"9.
4
"
>
<description
description=
""
title=
"Alarm Mail Notification"
sourcePath=
"/home/graziano/w
orkspace/fermi/server
s/alarmmail"
language=
"Python"
filestogenerate=
"XMI file,Code files,Protected Regions"
license=
"GPL"
hasMandatoryProperty=
"false"
hasConcreteProperty=
"true"
hasAbstractCommand=
"false"
hasAbstractAttribute=
"false"
>
<classes
name=
"AlarmMail"
pogoRevision=
"9.
6
"
>
<description
description=
""
title=
"Alarm Mail Notification"
sourcePath=
"/home/graziano/w
s/d
s/alarm
-
mail
/src
"
language=
"Python"
filestogenerate=
"XMI file,Code files,Protected Regions"
license=
"GPL"
hasMandatoryProperty=
"false"
hasConcreteProperty=
"true"
hasAbstractCommand=
"false"
hasAbstractAttribute=
"false"
>
<inheritances
classname=
"Device_Impl"
sourcePath=
""
/>
<identification
contact=
"at elettra.eu - graziano.scalamera"
author=
"graziano.scalamera"
emailDomain=
"elettra.eu"
classFamily=
"Miscellaneous"
siteSpecific=
""
platform=
"All Platforms"
bus=
"Not Applicable"
manufacturer=
"none"
reference=
""
/>
</description>
...
...
@@ -39,6 +39,10 @@
<type
xsi:type=
"pogoDsl:StringType"
/>
<status
abstract=
"false"
inherited=
"false"
concrete=
"true"
concreteHere=
"true"
/>
</deviceProperties>
<deviceProperties
name=
"egiga_url"
description=
"eGiga url"
>
<type
xsi:type=
"pogoDsl:StringType"
/>
<status
abstract=
"false"
inherited=
"false"
concrete=
"true"
concreteHere=
"true"
/>
</deviceProperties>
<commands
name=
"State"
description=
"This command gets the device state (stored in its device_state data member) and returns it to the caller."
execMethod=
"dev_state"
displayLevel=
"OPERATOR"
polledPeriod=
"0"
>
<argin
description=
"none"
>
<type
xsi:type=
"pogoDsl:VoidType"
/>
...
...
@@ -93,6 +97,6 @@
</argout>
<status
abstract=
"false"
inherited=
"false"
concrete=
"true"
concreteHere=
"true"
/>
</commands>
<preferences
docHome=
"./doc_html"
makefileHome=
"/usr/local/tango-9.
2.5a
/share/pogo/preferences"
/>
<preferences
docHome=
"./doc_html"
makefileHome=
"/usr/local/tango-9.
3.3
/share/pogo/preferences"
/>
</classes>
</pogoDsl:PogoSystem>
This diff is collapsed.
Click to expand it.
Preview
0%
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