Ejemplo n.º 1
0
 def upload(self, ana=False):
     if self.current_project_def == None:
         tkinter_messagebox.showwarning('', 'No project selected.')
         return
     if self.current_stage_def == None:
         tkinter_messagebox.showwarning('', 'No stage selected.')
         return
     top = self.winfo_toplevel()
     old_cursor = top['cursor']
     try:
         top['cursor'] = 'watch'
         top.update_idletasks()
         dim = project_utilities.dimensions_datastream(
             self.current_project_def, self.current_stage_def, ana=ana)
         project.docheck_locations(dim,
                                   self.current_stage_def.outdir,
                                   add=False,
                                   clean=False,
                                   remove=False,
                                   upload=True)
         top['cursor'] = old_cursor
     except:
         top['cursor'] = old_cursor
         e = sys.exc_info()
         traceback.print_tb(e[2])
         tkinter_messagebox.showerror('', e[1])
Ejemplo n.º 2
0
    def store( self, statusCode, istage, run, subrun ):

        # Only store the final stage.
        # If this is not the final stage, advance to the next stage.

        if istage != self._stage_digits[-1]:
            statusCode = self.kDONE
            istage += 10
            return statusCode + istage

        # Get stage name.
        stage = self._digit_to_name[istage]

        # Get project and stage object.
        try:
            probj, stobj = project.get_pubs_stage(self._xml_file, '', stage, run, subrun, self._version)
        except:
            self.error('Exception raied by project.get_pubs_stage:')
            e = sys.exc_info()
            for item in e:
                self.error(item)
            for line in traceback.format_tb(e[2]):
                self.error(line)
            return statusCode + istage 

        # Do store.
        try:
            real_stdout = sys.stdout
            real_stderr = sys.stderr
            sys.stdout = StringIO.StringIO()
            sys.stderr = StringIO.StringIO()

            # Store files.

            dim = project_utilities.dimensions(probj, stobj, ana=False)
            store_status = project.docheck_locations(dim, stobj.outdir, 
                                                     add=False,
                                                     clean=False,
                                                     remove=False,
                                                     upload=True)

            if store_status == 0:
                dim = project_utilities.dimensions(probj, stobj, ana=True)
                store_status = project.docheck_locations(dim, stobj.outdir, 
                                                         add=False,
                                                         clean=False,
                                                         remove=False,
                                                         upload=True)

            strout = sys.stdout.getvalue()
            strerr = sys.stderr.getvalue()
            sys.stdout = real_stdout
            sys.stderr = real_stderr
            if strout:
                self.info(strout)
            if strerr:
                self.warning(strerr)
        except:
            sys.stdout = real_stdout
            sys.stderr = real_stderr
            self.error('Exception raied by project.docheck_locations:')
            e = sys.exc_info()
            for item in e:
                self.error(item)
            for line in traceback.format_tb(e[2]):
                self.error(line)
            return statusCode + istage

        # Update pubs status.
        if store_status == 0:
           statusCode = self.kDONE
           istage += 10

        # Pretend I'm doing something
        time.sleep(5)

        # If all the stages complete, send an email to experts
        if not istage in self._stage_digits:
            subject = "Completed: MCC sample %s" % self._project
            text = """
Sample     : %s
Stage      : %s
               """ % ( self._project, self._digit_to_name[istage-10] )

            pub_smtp( os.environ['PUB_SMTP_ACCT'], os.environ['PUB_SMTP_SRVR'], os.environ['PUB_SMTP_PASS'], self._experts, subject, text )

        statusCode += istage
        self.info("SAM store, status: %d" % statusCode)

        # Pretend I'm doing something
        time.sleep(5)

        # Here we may need some checks

        return statusCode
Ejemplo n.º 3
0
    def store(self, statusCode, istage, run, subrun):

        # Only store the final stage.
        # If this is not the final stage, advance to the next stage.

        if istage != self._stage_digits[-1]:
            statusCode = self.kDONE
            istage += 10
            return statusCode + istage

        # Get stage name.
        stage = self._digit_to_name[istage]

        # Get project and stage object.
        try:
            probj, stobj = project.get_pubs_stage(self._xml_file, '', stage,
                                                  run, subrun, self._version)
        except:
            self.error('Exception raied by project.get_pubs_stage:')
            e = sys.exc_info()
            for item in e:
                self.error(item)
            for line in traceback.format_tb(e[2]):
                self.error(line)
            return statusCode + istage

        # Do store.
        try:
            real_stdout = sys.stdout
            real_stderr = sys.stderr
            sys.stdout = StringIO.StringIO()
            sys.stderr = StringIO.StringIO()

            # Store files.

            dim = project_utilities.dimensions(probj, stobj, ana=False)
            store_status = project.docheck_locations(dim,
                                                     stobj.outdir,
                                                     add=False,
                                                     clean=False,
                                                     remove=False,
                                                     upload=True)

            if store_status == 0:
                dim = project_utilities.dimensions(probj, stobj, ana=True)
                store_status = project.docheck_locations(dim,
                                                         stobj.outdir,
                                                         add=False,
                                                         clean=False,
                                                         remove=False,
                                                         upload=True)

            strout = sys.stdout.getvalue()
            strerr = sys.stderr.getvalue()
            sys.stdout = real_stdout
            sys.stderr = real_stderr
            if strout:
                self.info(strout)
            if strerr:
                self.warning(strerr)
        except:
            sys.stdout = real_stdout
            sys.stderr = real_stderr
            self.error('Exception raied by project.docheck_locations:')
            e = sys.exc_info()
            for item in e:
                self.error(item)
            for line in traceback.format_tb(e[2]):
                self.error(line)
            return statusCode + istage

        # Update pubs status.
        if store_status == 0:
            statusCode = self.kDONE
            istage += 10

        # Pretend I'm doing something
        time.sleep(5)

        # If all the stages complete, send an email to experts
        if not istage in self._stage_digits:
            subject = "Completed: MCC sample %s" % self._project
            text = """
Sample     : %s
Stage      : %s
               """ % (self._project, self._digit_to_name[istage - 10])

            pub_smtp(os.environ['PUB_SMTP_ACCT'], os.environ['PUB_SMTP_SRVR'],
                     os.environ['PUB_SMTP_PASS'], self._experts, subject, text)

        statusCode += istage
        self.info("SAM store, status: %d" % statusCode)

        # Pretend I'm doing something
        time.sleep(5)

        # Here we may need some checks

        return statusCode