Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
D
domotikad
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
domotika
domotikad
Commits
fb36fa66
Commit
fb36fa66
authored
Aug 15, 2014
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add source variable to action for email
parent
180c5712
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
domotika.py
domotika/domotika.py
+9
-9
dmmail.py
domotika/mail/dmmail.py
+10
-10
No files found.
domotika/domotika.py
View file @
fb36fa66
...
...
@@ -1160,7 +1160,7 @@ class domotikaService(service.Service):
if
'status'
in
args
.
keys
():
status
=
args
[
'status'
]
def
executeAction
(
self
,
command
):
def
executeAction
(
self
,
command
,
src
=
'internal'
):
def
multipleInsertNotify
(
dbres
,
nsrc
,
expire
,
msg
):
if
dbres
:
for
ue
in
dbres
:
...
...
@@ -1171,7 +1171,7 @@ class domotikaService(service.Service):
log
.
debug
(
command
)
command
=
command
[
7
:]
subprocess
.
Popen
(
command
.
replace
(
"
\r\n
"
,
" "
),
command
.
replace
(
"
\r\n
"
,
" "
)
.
replace
(
'[[SRC]]'
,
src
)
,
shell
=
True
,
preexec_fn
=
os
.
setsid
)
elif
command
.
startswith
(
"IOCONF "
)
or
command
.
startswith
(
"IOCONF:"
):
command
=
command
[
7
:]
...
...
@@ -1195,7 +1195,7 @@ class domotikaService(service.Service):
dmdb
.
updateNetStatus
(
nst
)
.
addCallback
(
self
.
sendNetStatus
,
True
)
elif
command
.
startswith
(
"EMAIL "
)
or
command
.
startswith
(
"EMAIL:"
):
mname
=
command
[
6
:]
email
.
sendEmailByName
(
mname
)
email
.
sendEmailByName
(
mname
,
sval
=
src
)
elif
command
.
startswith
(
"NOTIFY "
)
or
command
.
startswith
(
"NOTIFY:"
):
expire
=
time
.
time
()
+
float
(
self
.
config
.
get
(
"general"
,
"notify_expiretime"
))
...
...
@@ -1395,7 +1395,7 @@ class domotikaService(service.Service):
def
parseAction
(
self
,
res
,
restype
=
"action"
):
def
parseAction
(
self
,
res
,
restype
=
"action"
,
s
=
'internal'
):
if
restype
==
"action"
:
try
:
timedict
=
parseCronLine
(
...
...
@@ -1423,7 +1423,7 @@ class domotikaService(service.Service):
return
if
genutils
.
isTrue
(
res
.
execute
):
self
.
executeAction
(
res
.
command
)
self
.
executeAction
(
res
.
command
,
src
=
s
)
if
genutils
.
isTrue
(
res
.
ikapacket
):
self
.
sendCommand
(
res
.
ikap_dst
,
act
=
res
.
ikap_act
,
ctx
=
res
.
ikap_ctx
,
msgtype
=
res
.
ikap_msgtype
,
arg
=
res
.
ikap_arg
,
src
=
res
.
ikap_src
,
ipdst
=
str
(
res
.
ipdest
))
...
...
@@ -1990,16 +1990,16 @@ class domotikaService(service.Service):
return
False
return
True
def
manageRecvPkt
(
self
,
res
,
argdict
):
def
manageRecvPkt
(
self
,
res
,
argdict
,
src
=
'internal'
):
# XXX Usiamo un generator o reactor.callLater?
if
res
:
log
.
debug
(
"ManageRcvPkt "
+
str
(
res
))
for
r
in
res
:
if
genutils
.
isTrue
(
r
.
use_rcv_arg
):
if
argdict
and
self
.
checkRcvArg
(
r
.
rcv_arg
,
argdict
):
self
.
parseAction
(
r
)
self
.
parseAction
(
r
,
s
=
src
)
else
:
self
.
parseAction
(
r
)
self
.
parseAction
(
r
,
s
=
src
)
def
on_callback
(
self
,
who
,
cmd
,
*
args
,
**
kwargs
):
f
=
getattr
(
self
,
who
+
'_on_'
+
cmd
,
None
)
...
...
@@ -2699,7 +2699,7 @@ class domotikaService(service.Service):
dmdb
.
matchIncomingPacket
(
dst
,
src
,
ikahdr
.
msgtype
,
ikahdr
.
ctx
,
ikahdr
.
act
,
islocal
=
islocal
)
.
addCallback
(
self
.
manageRecvPkt
,
argdict
self
.
manageRecvPkt
,
argdict
,
src
)
events
.
postEvent
(
events
.
NetworkEvent
(
dst
,
src
,
ikahdr
,
arg
,
host
))
if
arg
:
...
...
domotika/mail/dmmail.py
View file @
fb36fa66
...
...
@@ -135,7 +135,7 @@ class DMEmail(object):
return
d
.
addCallbacks
(
self
.
end
)
def
_realSendMime
(
ser
,
res
):
def
_realSendMime
(
ser
,
res
,
sval
=
'internal'
):
if
ser
:
for
s
in
ser
:
e
=
DMEmail
()
...
...
@@ -154,19 +154,19 @@ def _realSendMime(ser, res):
e
.
setFrom
(
m
.
sender
)
e
.
setTo
(
m
.
to
.
split
(
','
))
e
.
setSubject
(
m
.
subject
)
e
.
setMessage
(
m
.
message
)
e
.
setMessage
(
m
.
message
.
replace
(
'[[SRCVAL]]'
,
sval
)
)
e
.
send
()
def
_sendEmailMime
(
res
):
def
_sendEmailMime
(
res
,
sval
=
'internal'
):
if
res
:
dmdb
.
EmailConf
.
find
()
.
addCallback
(
_realSendMime
,
res
)
dmdb
.
EmailConf
.
find
()
.
addCallback
(
_realSendMime
,
res
,
sval
)
def
_realSendMail
(
ser
,
sender
,
recipient
,
message
):
def
_realSendMail
(
ser
,
sender
,
recipient
,
message
,
sval
=
'internal'
):
if
ser
:
e
=
DMEmail
()
e
.
setFrom
(
sender
)
e
.
setTo
(
recipient
.
split
(
','
))
e
.
setMessage
(
message
)
e
.
setMessage
(
message
.
replace
(
'[[SRCVAL]]'
,
sval
)
)
for
s
in
ser
:
e
.
setServer
(
s
.
server
,
s
.
port
)
...
...
@@ -188,12 +188,12 @@ def sendMail(sender, recipient, message):
return
dmdb
.
EmailConf
.
find
()
.
addCallback
(
_realSendMail
,
sender
,
recipient
,
message
)
def
sendEmailByName
(
name
):
dmdb
.
Email
.
find
(
where
=
[
"name=?"
,
name
])
.
addCallback
(
_sendEmailMime
)
def
sendEmailByName
(
name
,
sval
=
'internal'
):
dmdb
.
Email
.
find
(
where
=
[
"name=?"
,
name
])
.
addCallback
(
_sendEmailMime
,
sval
)
def
sendEmailById
(
mailid
):
dbdb
.
Email
.
find
(
where
=
[
"id=?"
,
mailid
])
.
addCallback
(
_sendEmailMime
)
def
sendEmailById
(
mailid
,
sval
=
'internal'
):
dbdb
.
Email
.
find
(
where
=
[
"id=?"
,
mailid
])
.
addCallback
(
_sendEmailMime
,
sval
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment