Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rabbitmq_agents
Manage
Activity
Members
Labels
Plan
Issues
14
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
rc
rabbitmq_agents
Commits
79c32878
Commit
79c32878
authored
4 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Patches
Plain Diff
Send errmsg if error occur
parent
7c5ff0d1
No related branches found
Branches containing commit
No related tags found
4 merge requests
!147
Merge previous default branch feat-cod-rmq into main
,
!85
kill nginx process running under user from login node
,
!78
Feat cod rmq
,
!62
Feat notify user errmsg
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
notify_user.py
+5
-0
5 additions, 0 deletions
notify_user.py
with
5 additions
and
0 deletions
notify_user.py
+
5
−
0
View file @
79c32878
...
@@ -27,6 +27,7 @@ def notify_user(ch, method, properties, body):
...
@@ -27,6 +27,7 @@ def notify_user(ch, method, properties, body):
user_email
=
msg
[
'
email
'
]
user_email
=
msg
[
'
email
'
]
msg
[
'
task
'
]
=
task
msg
[
'
task
'
]
=
task
msg
[
'
success
'
]
=
False
msg
[
'
success
'
]
=
False
errmsg
=
""
try
:
try
:
...
@@ -34,6 +35,7 @@ def notify_user(ch, method, properties, body):
...
@@ -34,6 +35,7 @@ def notify_user(ch, method, properties, body):
record
=
table
.
find_one
(
username
=
username
)
record
=
table
.
find_one
(
username
=
username
)
if
record
[
'
sent
'
]
is
not
None
:
if
record
[
'
sent
'
]
is
not
None
:
errmsg
=
'
Updating database counter
'
# Update counter
# Update counter
count
=
record
[
'
count
'
]
count
=
record
[
'
count
'
]
if
args
.
dry_run
:
if
args
.
dry_run
:
...
@@ -58,11 +60,13 @@ def notify_user(ch, method, properties, body):
...
@@ -58,11 +60,13 @@ def notify_user(ch, method, properties, body):
logger
.
info
(
f
"
table.update({{
'
username
'
:
{
username
}
,
'
count
'
: 1,
'
sent_at
'
: datetime.now()}}, [
'
username
'
])
"
)
logger
.
info
(
f
"
table.update({{
'
username
'
:
{
username
}
,
'
count
'
: 1,
'
sent_at
'
: datetime.now()}}, [
'
username
'
])
"
)
else
:
else
:
errmsg
=
'
Sending email to user
'
smtp
=
smtplib
.
SMTP
(
mail_cfg
.
Server
)
smtp
=
smtplib
.
SMTP
(
mail_cfg
.
Server
)
smtp
.
sendmail
(
mail_cfg
.
Sender
,
receivers
,
message
)
smtp
.
sendmail
(
mail_cfg
.
Sender
,
receivers
,
message
)
logger
.
debug
(
f
'
Email sent to:
{
user_email
}
'
)
logger
.
debug
(
f
'
Email sent to:
{
user_email
}
'
)
errmsg
=
'
Updating database email sent time
'
table
.
update
({
table
.
update
({
'
username
'
:
username
,
'
username
'
:
username
,
'
count
'
:
1
,
'
count
'
:
1
,
...
@@ -74,6 +78,7 @@ def notify_user(ch, method, properties, body):
...
@@ -74,6 +78,7 @@ def notify_user(ch, method, properties, body):
msg
[
'
success
'
]
=
True
msg
[
'
success
'
]
=
True
except
Exception
as
exception
:
except
Exception
as
exception
:
logger
.
error
(
''
,
exc_info
=
True
)
logger
.
error
(
''
,
exc_info
=
True
)
msg
[
'
errmsg
'
]
=
errmsg
if
errmsg
else
'
Unexpected error
'
# Send confirm message
# Send confirm message
rc_rmq
.
publish_msg
({
rc_rmq
.
publish_msg
({
...
...
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