stuff
This commit is contained in:
13
generate.py
13
generate.py
@@ -9,6 +9,8 @@ import sys, os
|
|||||||
import pypandoc
|
import pypandoc
|
||||||
import argparse
|
import argparse
|
||||||
import quopri
|
import quopri
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
CONFIG_FILE = "generator.conf"
|
CONFIG_FILE = "generator.conf"
|
||||||
@@ -42,8 +44,9 @@ def get_body_text(msg):
|
|||||||
class Top:
|
class Top:
|
||||||
def __init__(self, title=None, sender=None, body=None, protostub=None, message=None):
|
def __init__(self, title=None, sender=None, body=None, protostub=None, message=None):
|
||||||
if message:
|
if message:
|
||||||
self.title = decode_header(message["Subject"])[6:]
|
self.title = decode_header(message["Subject"][6:])
|
||||||
real_name, address = email.utils.parseaddr(message["From"])
|
real_name, address = email.utils.parseaddr(message["From"])
|
||||||
|
real_name = decode_header(real_name)
|
||||||
self.sender = real_name or address
|
self.sender = real_name or address
|
||||||
payload = get_body_text(message)
|
payload = get_body_text(message)
|
||||||
self.body = str(payload.rpartition("\n--")[0] if "\n--" in payload else payload)
|
self.body = str(payload.rpartition("\n--")[0] if "\n--" in payload else payload)
|
||||||
@@ -125,10 +128,12 @@ if __name__ == "__main__":
|
|||||||
parser.add_argument("--config", default=CONFIG_FILE)
|
parser.add_argument("--config", default=CONFIG_FILE)
|
||||||
mode = parser.add_mutually_exclusive_group(required=True)
|
mode = parser.add_mutually_exclusive_group(required=True)
|
||||||
mode.add_argument("--invite", action="store_true")
|
mode.add_argument("--invite", action="store_true")
|
||||||
|
mode.add_argument("--mm-invite", action="store_true")
|
||||||
mode.add_argument("--presentation", action="store_true")
|
mode.add_argument("--presentation", action="store_true")
|
||||||
mode.add_argument("--protocol", action="store_true")
|
mode.add_argument("--protocol", action="store_true")
|
||||||
parser.add_argument("--debug", action="store_true", help=argparse.SUPPRESS)
|
parser.add_argument("--debug", action="store_true", help=argparse.SUPPRESS)
|
||||||
parser.add_argument("--write-mbox", action="store_true")
|
parser.add_argument("--write-mbox", action="store_true")
|
||||||
|
parser.add_argument("--send-mm", action="store_true")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
config = yaml.full_load(open(args.config))
|
config = yaml.full_load(open(args.config))
|
||||||
@@ -137,6 +142,8 @@ if __name__ == "__main__":
|
|||||||
template_file = config["invite_template_file"]
|
template_file = config["invite_template_file"]
|
||||||
elif args.presentation:
|
elif args.presentation:
|
||||||
template_file = config["presentation_template_file"]
|
template_file = config["presentation_template_file"]
|
||||||
|
elif args.mm_invite:
|
||||||
|
template_file = config["mminvite_template_file"]
|
||||||
elif args.protocol:
|
elif args.protocol:
|
||||||
template_file = config["protocol_template_file"]
|
template_file = config["protocol_template_file"]
|
||||||
else:
|
else:
|
||||||
@@ -204,5 +211,9 @@ if __name__ == "__main__":
|
|||||||
mbox.add(msg)
|
mbox.add(msg)
|
||||||
mbox.close()
|
mbox.close()
|
||||||
print(mbox)
|
print(mbox)
|
||||||
|
elif args.send_mm:
|
||||||
|
headers = {'Content-Type': 'application/json',}
|
||||||
|
values = json.dumps({ "text": template.render(context), "username": "test"})
|
||||||
|
response = requests.post(config["mm_url"], headers=headers, data=values)
|
||||||
else:
|
else:
|
||||||
print(template.render(context))
|
print(template.render(context))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ redeleitung:
|
|||||||
email: yannik.enss@fsmi.uni-karlsruhe.de
|
email: yannik.enss@fsmi.uni-karlsruhe.de
|
||||||
|
|
||||||
protokoll:
|
protokoll:
|
||||||
name: Alina Valta
|
name: Tobias Wiese
|
||||||
|
|
||||||
pre_tops:
|
pre_tops:
|
||||||
- title: Begrüßung
|
- title: Begrüßung
|
||||||
@@ -48,6 +48,7 @@ post_tops:
|
|||||||
- title: Sonstiges
|
- title: Sonstiges
|
||||||
|
|
||||||
invite_template_file: templates/fsr_einladung.j2
|
invite_template_file: templates/fsr_einladung.j2
|
||||||
|
mminvite_template_file: templates/fsr_einladung_mm.j2
|
||||||
presentation_template_file: templates/fsr_presentation.tex.j2
|
presentation_template_file: templates/fsr_presentation.tex.j2
|
||||||
protocol_template_file: templates/fsr_protokoll.j2
|
protocol_template_file: templates/fsr_protokoll.j2
|
||||||
|
|
||||||
@@ -63,5 +64,6 @@ place: Big Blue Button
|
|||||||
invite_mail: fsr-einladung@fsmi.uni-karlsruhe.de
|
invite_mail: fsr-einladung@fsmi.uni-karlsruhe.de
|
||||||
invite_subject: 'Einladung zum Fachschaftsrat am {{date|weekday}}, dem {{date|date}}'
|
invite_subject: 'Einladung zum Fachschaftsrat am {{date|weekday}}, dem {{date|date}}'
|
||||||
|
|
||||||
|
mm_url: https://mattermost.fsmi.uni-karlsruhe.de/hooks/xpqbpuxug3fsin5zwpcbuu11ky
|
||||||
|
|
||||||
# vim: filetype=yaml
|
# vim: filetype=yaml
|
||||||
|
|||||||
@@ -3,3 +3,8 @@
|
|||||||
./read_ubmails.py
|
./read_ubmails.py
|
||||||
./generate.py --presentation > data/presentation_$(date +%Y-%m-%d).tex
|
./generate.py --presentation > data/presentation_$(date +%Y-%m-%d).tex
|
||||||
|
|
||||||
|
cd data/presentation/
|
||||||
|
pdflatex ../presentation_$(date +%Y-%m-%d).tex
|
||||||
|
pdflatex ../presentation_$(date +%Y-%m-%d).tex
|
||||||
|
pdflatex ../presentation_$(date +%Y-%m-%d).tex
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user