Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pla_reminder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
vaclab
pla_reminder
Commits
8e81efb3
Commit
8e81efb3
authored
5 years ago
by
Thomas Bock
Browse files
Options
Downloads
Patches
Plain Diff
rdm, systemd
parent
68dc6f70
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+13
-0
13 additions, 0 deletions
README.md
pla_reminder.py
+35
-38
35 additions, 38 deletions
pla_reminder.py
pla_reminder.service
+11
-0
11 additions, 0 deletions
pla_reminder.service
pla_reminder.timer
+9
-0
9 additions, 0 deletions
pla_reminder.timer
with
68 additions
and
38 deletions
README.md
0 → 100644
+
13
−
0
View file @
8e81efb3
pla_reminder
------------
Fragt täglich 5:00 unter
http://a73434.berlin.ptb.de:5984/vl_db/_design/share/_view/pla_date
ob vor 20 Tagen ein oder mehrere Planungsdokumente erstellt wurden.
Falls ja wird eine E-Mails an:
vacuum.cal@ptb.de
gesendet.
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pla_reminder.py
100644 → 100755
+
35
−
38
View file @
8e81efb3
#!/usr/bin/env python3
import
requests
import
json
from
datetime
import
datetime
,
timedelta
db_url
=
"
http://a73434.berlin.ptb.de:5984/vl_db/_design/share/_view/pla_date
"
relay_url
=
"
http://a73434.berlin.ptb.de:55555
"
to_mail
=
"
thomas.bock@ptb.de
"
N
=
20
opening
=
{
'
male
'
:
{
"
en
"
:
"
Dear Mr. {name}
"
,
"
de
"
:
"
Sehr geehrter Herr {name}
"
"
en
"
:
"
Dear Mr. {name}
,
"
,
"
de
"
:
"
Sehr geehrter Herr {name}
,
"
},
'
female
'
:
{
"
en
"
:
"
Dear M
r
s. {name}
"
,
"
de
"
:
"
Sehr geehrte Frau {name}
"
"
en
"
:
"
Dear Ms. {name}
,
"
,
"
de
"
:
"
Sehr geehrte Frau {name}
,
"
},
'
none
'
:
{
'
none
'
:
{
"
en
"
:
"
Dear Ladies and Gentlemen,
"
,
"
de
"
:
"
Sehr geehrte Damen und Herren,
"
}
}
body
=
{
'
en
'
:
"
your reservation of the time slot {schedule_date} for calibration is about to expire.
\
n\
n
Would you like to order this calibration?
"
,
'
de
'
:
"
die Reservierung Ihres Kalibriertermins zum {schedule_date} läuft in Kürze ab.
\
n\
n
Möchten Sie diese Kalibrierung in Auftrag geben?
"
'
en
'
:
"
your reservation of the time slot {schedule_date} for calibration is about to expire.
\n
Would you like to order this calibration?
"
,
'
de
'
:
"
die Reservierung Ihres Kalibriertermins zum {schedule_date} läuft in Kürze ab.
\n
Möchten Sie diese Kalibrierung in Auftrag geben?
"
}
closing
=
{
'
en
'
:
"
Best regards
"
,
'
en
'
:
"
Best regards
,
"
,
'
de
'
:
"
Mit freundlichen Grüßen
"
}
suject
=
{
subject
=
{
'
en
'
:
"
Angebot vom {ref_date} (zum Weiterleiten an {email})
"
,
'
de
'
:
"
Offer from {ref_date} (zum Weiterleiten an {email})
"
}
N
=
15
date_N_days
=
datetime
.
now
()
-
timedelta
(
days
=
N
)
ref_date
=
str
(
date_N_days
).
split
(
"
"
)[
0
]
ref_date
=
"
2019-10-17
"
req
=
requests
.
get
(
"
{url}?key=
\"
{key}
\"
"
.
format
(
url
=
db_url
,
key
=
ref_date
))
plas
=
req
.
json
()
pla
nning
s
=
req
.
json
()
for
pla
in
plas
[
"
rows
"
]:
customer
=
pla
.
get
(
"
value
"
,{}).
get
(
"
Customer
"
,
{})
for
pla
in
plannings
[
"
rows
"
]:
schedule_date
=
pla
.
get
(
"
value
"
,{}).
get
(
"
ScheduleDate
"
)
contact
=
customer
.
get
(
"
Contact
"
)
lang
=
customer
.
get
(
"
Lang
"
,
"
en
"
)
name
=
contact
.
get
(
"
Name
"
)
gender
=
contact
.
get
(
"
Gender
"
,
"
none
"
)
email
=
contact
.
get
(
"
Email
"
)
mail_suject
=
suject
[
lang
].
format
(
ref_date
=
ref_date
,
email
=
email
)
mail_opening
=
opening
[
gender
][
lang
].
format
(
name
=
name
)
mail_body
=
body
[
lang
].
format
(
schedule_date
=
schedule_date
)
mail_closing
=
closing
[
lang
]
mail
=
"
{}
\n\n
{}
\n\n
{}
"
.
format
(
mail_opening
,
mail_body
,
mail_closing
)
task
=
{
"
Action
"
:
"
EMAIL
"
,
"
Host
"
:
"
smtp-hub.bs.ptb.de
"
,
"
Subject
"
:
mail_suject
,
"
From
"
:
"
<reminder@ptb.de>
"
,
"
To
"
:
"
Thomas.Bock@ptb.de
"
,
"
Text
"
:
mail
}
req
=
requests
.
post
(
relay_url
,
data
=
json
.
dumps
(
task
))
\ No newline at end of file
customer
=
pla
.
get
(
"
value
"
,{}).
get
(
"
Customer
"
)
if
schedule_date
and
customer
:
contact
=
customer
.
get
(
"
Contact
"
)
lang
=
customer
.
get
(
"
Lang
"
,
"
en
"
)
name
=
contact
.
get
(
"
Name
"
)
gender
=
contact
.
get
(
"
Gender
"
,
"
none
"
)
email
=
contact
.
get
(
"
Email
"
)
mail_subject
=
subject
[
lang
].
format
(
ref_date
=
ref_date
,
email
=
email
)
mail_opening
=
opening
[
gender
][
lang
].
format
(
name
=
name
)
mail_body
=
body
[
lang
].
format
(
schedule_date
=
schedule_date
)
mail_closing
=
closing
[
lang
]
mail
=
"
{}
\n\n
{}
\n\n
{}
"
.
format
(
mail_opening
,
mail_body
,
mail_closing
)
task
=
{
"
Action
"
:
"
EMAIL
"
,
"
Host
"
:
"
smtp-hub.bs.ptb.de
"
,
"
Subject
"
:
mail_subject
,
"
From
"
:
"
<reminder@ptb.de>
"
,
"
To
"
:
to_mail
,
"
Text
"
:
mail
}
req
=
requests
.
post
(
relay_url
,
data
=
json
.
dumps
(
task
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pla_reminder.service
0 → 100644
+
11
−
0
View file @
8e81efb3
[Unit]
Description
=
Planning document reminder
Documentation
=
https://a75436.berlin.ptb.de/thomas.bock/pla_reminder/blob/master/README.md
[Service]
Type
=
oneshot
Nice
=
15
ExecStart
=
/usr/local/share/pla_reminder/pla_reminder
[Install]
WantedBy
=
default.target
\ No newline at end of file
This diff is collapsed.
Click to expand it.
pla_reminder.timer
0 → 100644
+
9
−
0
View file @
8e81efb3
[Unit]
Description=Backup %H (Timer)
[Timer]
OnCalendar=6:15
Persistent=true
[Install]
WantedBy=timers.target
\ No newline at end of file
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