def notify_users(self):
     groups = self.db.get_groups()
     group_names = [(group.id, group.name) for group in groups]
     try:
         fromm, group_id, bcc, subject, text = self.ui.dialog_notify_users(
             group_names, self.default_notification_from,
             self.default_notification_bcc,
             self.default_notification_subject,
             self.default_notification_text_file)
         users = [group.users for group in groups if group.id == group_id
                  ][0] if group_id is not None else self.db.get_users()
         if len(users) > 0:
             smtp = SmtpGateway(self.smtp_host, self.smtp_helo)
             for user in users:
                 self.ui.notify_begin("Sending email to %s..." % user.email)
                 smtp.send(
                     fromm, (user.email, ) + bcc, subject, text % {
                         'FULL_NAME': user.full_name,
                         'LOGIN': user.login
                     })
                 self.ui.notify_end("done.")
         else:
             self.ui.error("The selected Group has no Users to notify.")
         self.ui.wait()
     except GoBackError:
         return
    def notify_users_with_passwords(self):
        """
        Will send a mail to every specified user with their welcome text. That welcome text
        will include the password. Because passwords are not stored in the database (only
        their hashes are), a "dbusers" file will need to be specified to extract the passwords
        from.
        """
        groups = self.db.get_groups()
        group_names = [(group.id, group.name) for group in groups]
        try:
            fromm, group_id, bcc, subject, text = self.ui.dialog_notify_users_with_passwords(
                group_names, self.default_notification_from,
                self.default_notification_bcc,
                self.default_notification_subject,
                self.default_notification_with_password_text_file)
            users = [group.users for group in groups if group.id == group_id
                     ][0] if group_id is not None else self.db.get_users()

            # The DB does not contain the passwords, so we will retrieve them from the DBUSERS file.
            users_from_file = self.ui.dialog_read_db_users_file_for_notify(
                self.default_db_users_file)

            # Store the passwords in a dictionary, associating them with the login names.
            user_pwds = {}
            for entry in users_from_file:
                user_pwds[entry[0]] = entry[3]

            if len(users) > 0 and len(users_from_file) > 0:

                smtp = SmtpGateway(self.smtp_host, self.smtp_helo)
                for user in users:
                    if (user.login in user_pwds):
                        pwd = user_pwds[user.login]
                        self.ui.notify_begin("Sending email to %s..." %
                                             user.email)
                        smtp.send(
                            fromm, (user.email, ) + bcc, subject, text % {
                                'FULL_NAME': user.full_name,
                                'LOGIN': user.login,
                                'PASSWORD': pwd
                            })
                        self.ui.notify_end("done.")
                    else:
                        self.ui.notify(
                            "[Warning]: Did not notify %s. The password is not available in the specified users file",
                            user.login)
            else:
                self.ui.error(
                    "The selected Group has no Users to notify, or the users file specified is empty."
                )
            self.ui.wait()
        except GoBackError:
            return
Beispiel #3
0
    def notify_users_with_passwords(self):
        """
        Will send a mail to every specified user with their welcome text. That welcome text
        will include the password. Because passwords are not stored in the database (only
        their hashes are), a "dbusers" file will need to be specified to extract the passwords
        from.
        """
        groups = self.db.get_groups()
        group_names = [ (group.id, group.name) for group in groups ]
        try:
            fromm, group_id, bcc, subject, text = self.ui.dialog_notify_users_with_passwords(
                                                            group_names,
                                                            self.default_notification_from,
                                                            self.default_notification_bcc,
                                                            self.default_notification_subject,
                                                            self.default_notification_with_password_text_file
                                                     )
            users = [ group.users for group in groups if group.id == group_id ][0] if group_id is not None else self.db.get_users()

            # The DB does not contain the passwords, so we will retrieve them from the DBUSERS file.
            users_from_file = self.ui.dialog_read_db_users_file_for_notify(self.default_db_users_file)

            # Store the passwords in a dictionary, associating them with the login names.
            user_pwds = {}
            for entry in users_from_file:
                user_pwds[entry[0]] = entry[3]

            if len(users) > 0 and len(users_from_file) > 0:

                smtp = SmtpGateway(self.smtp_host, self.smtp_helo)
                for user in users:
                    if( user.login in user_pwds ):
                        pwd = user_pwds[user.login]
                        self.ui.notify_begin("Sending email to %s..." % user.email)
                        smtp.send(fromm, (user.email,) + bcc, subject, text % {'FULL_NAME': user.full_name, 'LOGIN': user.login, 'PASSWORD': pwd})
                        self.ui.notify_end("done.")
                    else:
                        self.ui.notify("[Warning]: Did not notify %s. The password is not available in the specified users file", user.login)
            else:
                self.ui.error("The selected Group has no Users to notify, or the users file specified is empty.")
            self.ui.wait()
        except GoBackError:
            return
Beispiel #4
0
 def notify_users(self):
     groups = self.db.get_groups()
     group_names = [ (group.id, group.name) for group in groups ]
     try:
         fromm, group_id, bcc, subject, text = self.ui.dialog_notify_users(
                                                         group_names,
                                                         self.default_notification_from,
                                                         self.default_notification_bcc,
                                                         self.default_notification_subject,
                                                         self.default_notification_text_file
                                                  )
         users = [ group.users for group in groups if group.id == group_id ][0] if group_id is not None else self.db.get_users()
         if len(users) > 0:
             smtp = SmtpGateway(self.smtp_host, self.smtp_helo)
             for user in users:
                 self.ui.notify_begin("Sending email to %s..." % user.email)
                 smtp.send(fromm, (user.email,) + bcc, subject, text % {'FULL_NAME': user.full_name, 'LOGIN': user.login})
                 self.ui.notify_end("done.")
         else:
             self.ui.error("The selected Group has no Users to notify.")
         self.ui.wait()
     except GoBackError:
         return