コード例 #1
0
ファイル: models.py プロジェクト: FOSSEE-Internship/SBHS-2017
 def send_password_link(self, token):
     """ Function to show message to user to visit the link in order to change the password.
     """
     message = """Hi,\n\nPlease visit the link """ + settings.BASE_URL + """password/edit/"""
     message = message + token
     message = message + """ to change your password.\n\n\nRegards,\nVlabs Team"""
     mailer.email(self.email, "SBHS vlabs password reset link", message)
コード例 #2
0
ファイル: models.py プロジェクト: FOSSEE-Internship/SBHS-2017
 def send_confirmation(self):
     """ Function to show message to the user to confirm their account by visiting the link sent
         to their e-mail.
     """
     message = """Hi,\n\nPlease visit the link """ + settings.BASE_URL + """account/confirm/"""
     message = message + self.confirmation_token()
     message = message + """ to confirm your account.\n\n\nRegards,\nVlabs Team"""
     mailer.email(self.email, "Please confirm your account", message)
コード例 #3
0
def main():
    """ Attempts to open serial port object on existing USB paths, and then read the mid of the device using read_from port() function.
        Sets fan and heater value to 100 and 0 respectively using write_to_port() function,
        and reads the temperature of the same device using read_from port() function.
        if the serial port opens but the mid returned is less than zero
            append it to the list of defective ports.
        if an exception occurs while reading or writing but the port opens successfully and returns a valid mid
            then add it to the list of offline mids.
        if the ports opens successfully, returns a valid mid and temperature, and encounters no exceptions
            then add it to the list of present_online_mids
        The difference between the sets of online_mids and present_online_mids gives the list of mids of devices to be checked.
        Calls the create_message function and mails the returned message to the admin.
    """
    present_online_mids, offline_mids, defective_ports = [], [], []
    for i in range(0, MAX_PORTS):
        path = '/dev/ttyUSB' + str(i)
        if os.path.exists(path):
            try:
                s = serial.Serial(port=path,
                                  baudrate=9600,
                                  bytesize=8,
                                  parity='N',
                                  stopbits=1,
                                  timeout=2)
                if not s.is_open:
                    s.open()
                assert s.is_open
                mid = read_from_port(s, 252)  # get machine id
                assert mid > 0
                write_to_port(s, 253, 100)  # set fan speed
                write_to_port(s, 254, 0)  # set heater value
                current_temp = read_from_port(s,
                                              255)  # get current temperature
                assert current_temp >= MIN_TEMP and current_temp <= MAX_TEMP
                present_online_mids.append(mid)
            except:
                if s.is_open:
                    if mid > 0:
                        offline_mids.append(mid)
                    else:
                        defective_ports.append(path)
            if s.is_open:
                s.close()
    check_mids = list(set(online_mids).difference(set(present_online_mids)))
    msg = create_message(check_mids, defective_ports)
    if len(msg) == 0:
        msg = "Nothing out of order was detected on the server. :)"
    #thread.start_new_thread(mailer.email, (ADMIN_EMAIL, "Health report of SBHS Server", msg))
    mailer.email(ADMIN_EMAIL, "Health report of SBHS Server", msg)
コード例 #4
0
ファイル: models.py プロジェクト: Rupesh-Gupta/SBHS-Vlabs
 def send_confirmation(self):
     message = """Hi,\n\nPlease visit the link """ + settings.BASE_URL + """account/confirm/"""
     message = message + self.confirmation_token()
     message = message + """ to confirm your account.\n\n\nRegards,\nVlabs Team"""
     mailer.email(self.email, "Please confirm your account", message)