Ejemplo n.º 1
0
 def notify_start_of_call(self):
     """
     sends notification email informing user that ``self.call_id`` has been initiated
     """
     e = self.email_info
     
     report_time = get_time()
     email_sub="[SITREP from %s] Run %s - Starting %s at %s" % (self._hostname,self.run_id,self.call_id,report_time)
     email_body="%s\n\n%s" % (email_sub,self.cmd_string)
     server_info = self.yargs.run_options.custom_smtp
     email_notification(e.email_from, e.email_to, email_sub, email_body, base64.b64decode(e.email_li), server_info)
Ejemplo n.º 2
0
    def notify_end_of_call(self):
        """
        sends notification email informing user that ``self.call_id`` has exited
        """
        e = self.email_info

        report_time = get_time()
        email_sub="[SITREP from %s] Run %s - Exited %s at %s" % (self._hostname,self.run_id,self.call_id,report_time)

        #    repeat subject in body
        email_body=email_sub
        
        email_body += "\n\n ==> stderr <==\n\n%s" % (self.stderr_msg)
        server_info = self.yargs.run_options.custom_smtp
        email_notification(e.email_from, e.email_to, email_sub, email_body, base64.b64decode(e.email_li), server_info)
Ejemplo n.º 3
0
    def execute(self):
        """
        calls correct program, records results, and manages errors
        """
        
        self.cmd_string = "%s %s" % (self.prog_name,self.arg_str)
        if self.mode == 'analyze':
            try:
                self.notify_start_of_call()
                self.log_start()
    
                self.stdout_msg,self.stderr_msg = runExternalApp(progName=self.prog_name,argStr=self.arg_str)
    
                self.log_end()
                self.notify_end_of_call()
            except Exception as exc:
                email_body = traceback.format_exc()
                email_body = self.purge_progress_bars(email_body)
                e = self.email_info
                server_info = self.yargs.run_options.custom_smtp

                self.stdout_msg = "\nError in call.  Check error log.\n"
                self.stderr_msg = email_body
    
                self.log_end()
    
                self._flag_out_dir()
    
                if isinstance(exc,errors.SystemCallError):
                    email_sub="[SITREP from %s] Run %s experienced SystemCallError in call %s. MOVING ON." % (self._hostname,self.run_id,self.call_id)
                    email_notification(e.email_from, e.email_to, email_sub, email_body, base64.b64decode(e.email_li),server_info)                
                elif isinstance(exc,KeyboardInterrupt):
                    email_sub="[SITREP from %s] Run %s experienced KeyboardInterrupt in call %s. MOVING ON." % (self._hostname,self.run_id,self.call_id)
                    email_notification(e.email_from, e.email_to, email_sub, email_body, base64.b64decode(e.email_li),server_info) 
                else:
                    email_sub="[SITREP from %s] Run %s experienced unhandled exception in call %s. EXITING." % (self._hostname,self.run_id,self.call_id)
                    email_notification(e.email_from, e.email_to, email_sub, email_body, base64.b64decode(e.email_li),server_info)
                    raise
        
        # DRY RUN
        elif self.mode == 'dry_run':
            print self.cmd_string + '\n'
        
        # QSUB SCRIPT
        elif self.mode == 'qsub_script':
            self.build_qsub()
        else:
            raise errors.BlacktieError()