aboutsummaryrefslogtreecommitdiff
path: root/bugzilla/usr/bin/bugzilla_fetch.py
blob: b4a98059b75572b5a2d4df2b31cf2d76012ef864 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python

import boto3
import subprocess


client = boto3.client("s3")
bucket = "mcrute-bugs-emails"
email_bin = "/var/www/html/bugzilla/email_in.pl"
items = client.list_objects_v2(Bucket=bucket)


for item in items["Contents"]:
    key = item["Key"]

    if key == "AMAZON_SES_SETUP_NOTIFICATION":
        continue

    body = client.get_object(Bucket=bucket, Key=key)["Body"]

    cmd = subprocess.Popen([email_bin], stdin=subprocess.PIPE)
    cmd.communicate(body.read())

    client.delete_object(Bucket=bucket, Key=key)