예제 #1
0
파일: mail.py 프로젝트: javrodriguez/snsxt
def sns_start_email(analysis_dir, **kwargs):
    """
    Emails the user when the sns pipeline starts

    Parameters
    ----------
    analysis_dir: str
        path to a directory to hold the analysis output
    kwargs: dict
        dictionary containing extra args to pass to `run_tasks`

    """
    recipient_list = kwargs.pop('recipient_list', notification_recipients)
    reply_to = kwargs.pop('reply_to', default_reply_to)
    subject_line = kwargs.pop('subject_line', notification_subject_line_base)

    subject_line = subject_line + ' sns analysis started'

    message = "sns analysis started in directory:\n{0}".format(analysis_dir)

    mail_command = mutt.mutt_mail(recipient_list=recipient_list,
                                  reply_to=reply_to,
                                  subject_line=subject_line,
                                  message=message,
                                  return_only_mode=True)
    run_cmd = tools.SubprocessCmd(command=mail_command).run()
    # print run command output messages
    logger.debug(run_cmd.proc_stdout)
    logger.debug(run_cmd.proc_stderr)
예제 #2
0
파일: mail.py 프로젝트: javrodriguez/snsxt
def email_output(message_file, *args, **kwargs):
    """
    Sends an email upon the successful completion of the analysis pipeline. If any ``email_files`` were set by the program while running, they will be validated and included as email attachments.

    Parameters
    ----------
    message_file: str
        path to a file to use as the body of the email, typically the program's log file
    args: list
        a list containing extra args to pass to ``email_output()``
    kwargs: dict
        a dictionary containing extra args to pass to ``email_output()``

    Keyword Arguments
    -----------------
    recipient_list: str
        the recipients for the email, in the format ``recipient_list = "[email protected],[email protected]" ``
    reply_to: str
        email address to use in the 'Reply To' field of the email
    subject_line: str
        the subject line that should be used for the email
    """
    recipient_list = kwargs.pop('recipient_list', default_recipients)
    reply_to = kwargs.pop('reply_to', default_reply_to)
    subject_line = kwargs.pop('subject_line', success_subject_line_base)

    validate_email_files()

    logger.debug('email_files: {0}'.format(email_files))

    mail_command = mutt.mutt_mail(recipient_list=recipient_list,
                                  reply_to=reply_to,
                                  subject_line=subject_line,
                                  message_file=message_file,
                                  attachment_files=email_files,
                                  return_only_mode=True)
    run_cmd = tools.SubprocessCmd(command=mail_command).run()
    # print run command output messages
    logger.debug(run_cmd.proc_stdout)
    logger.debug(run_cmd.proc_stderr)
    # check for success of the command
    if run_cmd.process.returncode != 0:
        err_message = 'The mutt email command did not complete successfully'
        raise _e.SubprocessCmdError(message=err_message, errors='')
    def email_results(self):
        '''
        Send an email using the object's INFO log as the body of the message
        '''
        email_recipients = self.email_recipients
        email_subject_line = self.email_subject_line
        reply_to = self.reply_to
        message_file = log.logger_filepath(logger=self.logger,
                                           handler_name='emaillog')

        email_command = mutt.mutt_mail(
            recipient_list=email_recipients,
            reply_to=reply_to,
            subject_line=email_subject_line,
            message=
            'This message should have been replaced by the script log file contents. If you are reading it, something broke, sorry',
            message_file=message_file,
            return_only_mode=True,
            quiet=True)

        self.logger.debug('Email command is:\n\n{0}\n\n'.format(email_command))
        mutt.subprocess_cmd(command=email_command)
예제 #4
0
def email_notification(new_runs_dict):
    '''
    Send an email notifcation about the new runs
    '''
    reply_to_address = t.reply_to_address(
        servername=configs['reply_to_servername'])
    email_recipients = configs['email_recipients']
    email_subject_line = '[IonTorrent] Runs Available For Analysis'

    message_file = emaillog_handler_path

    email_command = mutt.mutt_mail(
        recipient_list=email_recipients,
        reply_to=reply_to_address,
        subject_line=email_subject_line,
        message=
        'This message should have been replaced by the script log file contents. If you are reading it, something broke, sorry',
        message_file=message_file,
        return_only_mode=True,
        quiet=True)

    logger.debug('Email command is:\n\n{0}\n\n'.format(email_command))

    mutt.subprocess_cmd(command=email_command)