def upload(self, ana=False): if self.current_project_def == None: tkMessageBox.showwarning('', 'No project selected.') return if self.current_stage_def == None: tkMessageBox.showwarning('', 'No stage selected.') return top = self.winfo_toplevel() old_cursor = top['cursor'] try: top['cursor'] = 'watch' top.update_idletasks() dim = project_utilities.dimensions(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]) tkMessageBox.showerror('', e[1])
def check_definition(self, ana=False): if self.current_project_def == None: tkMessageBox.showwarning('', 'No project selected.') return if self.current_stage_def == None: tkMessageBox.showwarning('', 'No stage selected.') return top = self.winfo_toplevel() old_cursor = top['cursor'] defname = '' if ana: defname = self.current_stage_def.ana_defname else: defname = self.current_stage_def.defname try: top['cursor'] = 'watch' top.update_idletasks() dim = project_utilities.dimensions(self.current_project_def, self.current_stage_def, ana=ana) project.docheck_definition(defname, dim, define=False) top['cursor'] = old_cursor except: top['cursor'] = old_cursor e = sys.exc_info() traceback.print_tb(e[2]) tkMessageBox.showerror('', e[1])
def test_declarations(self, ana=False): if self.current_project_def == None: tkMessageBox.showwarning('', 'No project selected.') return if self.current_stage_def == None: tkMessageBox.showwarning('', 'No stage selected.') return top = self.winfo_toplevel() old_cursor = top['cursor'] try: top['cursor'] = 'watch' top.update_idletasks() dim = project_utilities.dimensions(self.current_project_def, self.current_stage_def, ana=ana) project.dotest_declarations(dim) top['cursor'] = old_cursor except: top['cursor'] = old_cursor e = sys.exc_info() traceback.print_tb(e[2]) tkMessageBox.showerror('', e[1])
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
def declare( self, statusCode, istage, run, subrun ): # 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 declaration. try: real_stdout = sys.stdout real_stderr = sys.stderr sys.stdout = StringIO.StringIO() sys.stderr = StringIO.StringIO() # Declare artroot files. declare_status = project.docheck_declarations(stobj.logdir, stobj.outdir, declare=True, ana=False) # Declare analysis root files. if declare_status == 0: declare_status = project.docheck_declarations(stobj.logdir, stobj.outdir, declare=True, ana=True) # Create artroot dataset definition. if declare_status == 0: dim = project_utilities.dimensions(probj, stobj, ana=False) declare_status = project.docheck_definition(stobj.defname, dim, True) # Create analysis dataset definition. if declare_status == 0: dim = project_utilities.dimensions(probj, stobj, ana=True) declare_status = project.docheck_definition(stobj.defname, dim, 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_declarations:') 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 declare_status == 0: statusCode = self.kDECLARED statusCode += istage self.info("SAM declarations, status: %d" % statusCode) # Pretend I'm doing something time.sleep(5) # Here we may need some checks return statusCode
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
def declare(self, statusCode, istage, run, subrun): # 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 declaration. try: real_stdout = sys.stdout real_stderr = sys.stderr sys.stdout = StringIO.StringIO() sys.stderr = StringIO.StringIO() # Declare artroot files. declare_status = project.docheck_declarations(stobj.logdir, stobj.outdir, declare=True, ana=False) # Declare analysis root files. if declare_status == 0: declare_status = project.docheck_declarations(stobj.logdir, stobj.outdir, declare=True, ana=True) # Create artroot dataset definition. if declare_status == 0: dim = project_utilities.dimensions(probj, stobj, ana=False) declare_status = project.docheck_definition( stobj.defname, dim, True) # Create analysis dataset definition. if declare_status == 0: dim = project_utilities.dimensions(probj, stobj, ana=True) declare_status = project.docheck_definition( stobj.defname, dim, 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_declarations:') 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 declare_status == 0: statusCode = self.kDECLARED statusCode += istage self.info("SAM declarations, status: %d" % statusCode) # Pretend I'm doing something time.sleep(5) # Here we may need some checks return statusCode