Calendar: remove past event
[tails/test.git] / bin / generate-security-advisory
blob2596ba6518a080fd6e054aeb895bdf72392c8bed
1 #! /usr/bin/python3
3 import email.utils
4 import subprocess
6 from datetime import datetime, timedelta
7 import jinja2
10 def advisory_date() -> datetime:
11     changelog_entry_timestamp = subprocess.run(
12         ["dpkg-parsechangelog", "--show-field", "Timestamp"],
13         stdout=subprocess.PIPE,
14         universal_newlines=True,
15         check=True).stdout.rstrip()
16     return datetime.fromtimestamp(
17         float(changelog_entry_timestamp)) - timedelta(days=2)
20 def security_advisory_contents(args) -> str:
21     jinja2_env = jinja2.Environment(
22         loader=jinja2.FileSystemLoader('config/release_management/templates'))
24     return (jinja2_env.get_template('security_advisory.mdwn').render(
25         date=email.utils.format_datetime(advisory_date()),
26         previous_version=args.previous_version,
27         version=args.version,
28         tag=args.tag))
31 if __name__ == '__main__':
32     import argparse
33     parser = argparse.ArgumentParser()
34     parser.add_argument('--previous-version', required=True)
35     parser.add_argument('--version', required=True)
36     parser.add_argument('--tag', required=True)
37     args = parser.parse_args()
39     print(security_advisory_contents(args))