def getEmailsAndProjects(self): """ Go through projects and create a hash where Keys are Emails and Values are the projects associated with that email """ emails_and_projects = defaultdict(dict) for project in self.projects: for sample in self.projects[project]: email_address = self.projects[project][sample]["owner_email"] if project not in emails_and_projects[email_address]: emails_and_projects[email_address][project] = [sample] else: emails_and_projects[email_address][project].append(sample) self.emails_and_projects = emails_and_projects try: self.notifications except AttributeError: self.notifications = notifications()
def bclCompleteEmailBlast(self): try: self.notifications except AttributeError: self.notifications = notifications() for email in self.emails_and_projects: subject = "Analysis Complete for %s!" % (os.path.basename(self.run)) projects = [self.run + "/" + self.bcl_output_dir + "/Project_" + project for project in self.emails_and_projects[email].keys()] message = "%s has completed its analysis!\n\nHere are the Paths to your Projects:\n\n%s" % (os.path.basename(self.run),"\n".join(projects)) self.notifications.send_message(TO=[email],SUBJECT=subject,TEXT=message)
def adminRunInfoBlast(self,subject_message,inner_message): """ """ try: self.notifications except AttributeError: self.notifications = notifications() projects = ["- " + project for project in self.projects.keys()] projects.sort() subject = "%s for %s" % (subject_message,os.path.basename(self.run)) message = "%s for %s\n\nPATH on %s:\n%s\n\nPROJECTS:\n%s" % (inner_message,os.path.basename(self.run),self.host.upper(),self.run,"\n".join(projects)) for address in self.notifications.admin: self.notifications.send_message(TO=[address],SUBJECT=subject,TEXT=message)
def bclStartEmailBlast(self): """ """ try: self.notifications except AttributeError: self.notifications = notifications() for email in self.emails_and_projects: subject = "Bcl Analysis Has Started for %s" % (os.path.basename(self.run)) # I'm sorry this is a heinously long string # The Text would not format correctly if not done this way :-) message = """Just a friendly reminder from GAL-E to let you know that the following run:\n\n%s has started it's Bcl Analysis.\n\nI'll send you an email with the path(s) to your project(s) on the server when it's done.\n""" % (os.path.basename(self.run)) # API Note: send_message expects a list of email addresses. self.notifications.send_message(TO=[email],SUBJECT=subject,TEXT=message)