#example.py #!/usr/bin/env python3 import emails import os import reports table_data = [['Name', 'Amount', 'Value'], ['elderberries', 10, 0.45], ['figs', 5, 3], ['apples', 4, 2.75], ['durians', 1, 25], ['bananas', 5, 1.99], ['cherries', 23, 5.80], ['grapes', 13, 2.48], ['kiwi', 4, 0.49]] reports.generate("/tmp/report.pdf", "A Complete Inventory of My Fruit", "This is all my fruit.", table_data) sender = "*****@*****.**" receiver = "{}@example.com".format(os.environ.get('USER')) subject = "List of Fruits" body = "Hi\n\nI'm sending an attachment with all my fruit." message = emails.generate(sender, receiver, subject, body, "/tmp/report.pdf") emails.send(message)
s8 = fruits[7] s9 = fruits[8] s10 = fruits[9] s11 = fruits[10] s12 = fruits[11] s13 = fruits[12] s14 = fruits[13] s15 = fruits[14] s16 = fruits[15] s17 = fruits[16] s18 = fruits[17] s19 = fruits[18] s20 = fruits[19] x = datetime.datetime.now() title = "Processed Update on" + str(x.strftime("%B")) + str( x.strftime("%d")) + ',' + str(x.year) """Step 2""" reports.generate("/path/to/destination/result.pdf", title, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20) """Step 3""" sender = "*****@*****.**" receiver = "*****@*****.**" subject = "Upload Completed - Online Fruit Store" body = "All fruits are uploaded to our website successfully. A detailed list is attached to this email." message = emails.generate(sender, receiver, subject, body, "/tmp/processed.pdf") emails.send(message)
def generate_report(filename, title, additional_info, table_data): summary = '' for line in additional_info: summary += line + '<br/>' reports.generate(filename, title, summary, table_data)
def report(string_to_repo): today = date.today() title = "Processed Update on {}".format(today) reports.generate("processed.pdf", title, string_to_repo) reports.generate("/tmp/processed.pdf", title, string_to_repo)