Skip to content

Commit

Permalink
DD-1624 Extra options for deposit-create-report
Browse files Browse the repository at this point in the history
  • Loading branch information
aliassheikh committed Aug 22, 2024
1 parent be4c6cf commit 9200ec1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/datastation/common/send_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SendMail:
# pass

@staticmethod
def send(to_email, subject, message_body, attachment, cc_email, bcc_email):
def send(to_email, subject, message_body, attachment, email_from_address, cc_email, bcc_email):
recipients = to_email

if cc_email is not None:
Expand All @@ -18,7 +18,12 @@ def send(to_email, subject, message_body, attachment, cc_email, bcc_email):
if bcc_email is not None:
recipients = ' -b {0} {1} '.format(bcc_email, recipients)

email_addresses = recipients

if email_from_address is not None:
email_addresses = ' -r {0} {1} '.format(email_from_address, email_addresses)

if attachment is not None:
os.system('echo "{0}" | mail -s "{1}" -a "{2}" {3}'.format(message_body, subject, attachment, recipients))
os.system('echo "{0}" | mail -s "{1}" -a "{2}" {3}'.format(message_body, subject, attachment, email_addresses))
else:
os.system('echo "{0}" | mail -s "{1}" {2}'.format(message_body, subject, recipients))
os.system('echo "{0}" | mail -s "{1}" {2}'.format(message_body, subject, email_addresses))
2 changes: 2 additions & 0 deletions src/datastation/deposit_create_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def send_report_mail(self, attachment):
"Deposits report",
"Please, find attached the detailed report of deposits.",
attachment,
self.__command_line_args.email_from_address,
self.__command_line_args.cc_email_to,
self.__command_line_args.bcc_email_to)

Expand All @@ -46,6 +47,7 @@ def main():
parser.add_argument('-t', '--state', help='The state of the deposit')
parser.add_argument('-u', '--user', dest='user', help='The depositor name')
parser.add_argument('-f', '--format', dest='file_format', default='text/csv', help='Output data format')
parser.add_argument('r', 'from', dest='email_from_address', help='from address')
parser.add_argument('--email-to', dest='email_to', help='when more than one recipient: comma separated emails')
parser.add_argument('--cc-email-to', dest='cc_email_to', help='will be sent only if email-to is defined')
parser.add_argument('--bcc-email-to', dest='bcc_email_to', help='will be sent only if email-to is defined')
Expand Down

0 comments on commit 9200ec1

Please sign in to comment.