예제 #1
0
            actions.append('Quota ' + str(index[2]) + ' max=' +
                           str(max_quota) + ' ' + queryurl)
        except Exception as e:
            detail = str(e)
            actions.append('Quota FAIL ' + str(index[2]) + ' max=' +
                           str(max_quota) + ' ' + queryurl + ' ' + detail)
        # break

indices.sort(key=lambda indices: indices[1], reverse=True)
for index in indices:
    if index[1] > max_days:
        queryurl = url + '/' + index[0]
        try:
            if not dryrun: response = requests.delete(queryurl)
            actions.append('Expire ' + str(index[1]) + ' max=' +
                           str(max_days) + ' ' + queryurl)
        except Exception as e:
            detail = str(e)
            actions.append('Expire FAIL ' + str(index[1]) + ' max=' +
                           str(max_days) + ' ' + queryurl + ' ' + detail)
        # break

# Send some email
if len(actions) > 0:
    message = "Subject: Elastic Search Actions (" + str(len(actions)) + ")\n\n"
    if dryrun: message = message + "This is a dry run\n\n"
    for action in actions:
        message = message + action + "\n"
    print(message)
    myutils.sendMail(message)
예제 #2
0
import myutils

from email.message import EmailMessage

message = """\
Subject: Hi there

This YADA message is sent from Python."""

myutils.sendMail(message, "*****@*****.**")