class NotifyAuthorAboutRestore(Command): def __init__(self, project, env): Command.__init__(self) self.name = "NotifyAuthorAboutRestore" self.project = project self.notifier = NotificationSystem(env) from_email = env.config['notification'].get('smtp_from') replyto_email = env.config['notification'].get('smtp_replyto') self.from_email = from_email or replyto_email def do(self): author = self.project.author try: if author: txt = "Your project '" + self.project.project_name + "' have been restored and should " txt += "be accessible in " + self.project.get_url() + "\n\n" txt += "Permissions have not been restored automatically. You should add manually all " txt += "permissions again. Listings in the below will help if you want to give similar " txt += "permissions that project used to have.\n\n" team = self.project.archive_path + "/team.txt" f = open(team, 'r') txt += f.read() f.close() self.notifier.send_email(self.from_email, author.mail, txt) except Exception, e: conf.log.debug("Writing restore notification failed.") conf.log.exception(e) return True
class NotifyAuthorAboutRestore(Command): def __init__(self, project, env): Command.__init__(self) self.name = "NotifyAuthorAboutRestore" self.project = project self.notifier = NotificationSystem(env) from_email = env.config["notification"].get("smtp_from") replyto_email = env.config["notification"].get("smtp_replyto") self.from_email = from_email or replyto_email def do(self): author = self.project.author try: if author: txt = "Your project '" + self.project.project_name + "' have been restored and should " txt += "be accessible in " + self.project.get_url() + "\n\n" txt += "Permissions have not been restored automatically. You should add manually all " txt += "permissions again. Listings in the below will help if you want to give similar " txt += "permissions that project used to have.\n\n" team = self.project.archive_path + "/team.txt" f = open(team, "r") txt += f.read() f.close() self.notifier.send_email(self.from_email, author.mail, txt) except Exception, e: conf.log.debug("Writing restore notification failed.") conf.log.exception(e) return True
def send_mail(message, receiver): env = Environment(conf.getEnvironmentSysPath(conf.sys_home_project_name)) notifier = NotificationSystem(env) from_email = env.config['notification'].get('smtp_from') replyto_email = env.config['notification'].get('smtp_replyto') sender = from_email or replyto_email try: notifier.send_email(sender, receiver, message) except Exception as e: error_exit(e) return True