Home > python > Get an email notification when a site is up

Get an email notification when a site is up

Today I wanted to submit a paper to a conference but the site that manages submissions (EasyChair) is down for maintenance. I got this message:

EasyChair is Being Moved to a New Server

Quite unexpectedly, EasyChair had to be moved to a new server.

We are moving the system itself and restoring all data. We are sorry for any inconveniences caused.

The move is to be completed during Friday, May the 9th. We cannot give precise time at the moment. We are working hard to make it up and running as soon as possible.

I don’t want to check this site manually. How could I get notified when the site is up?

I wrote a simple script that regularly checks the site. When it’s up, it sends me an email notification and quits.

Here I reused some functions from my jabbapylib library. You can easily include those functions to make it standalone.

#!/usr/bin/env python
# encoding: utf-8

from __future__ import (absolute_import, division,
                        print_function, unicode_literals)

from time import sleep

import schedule

from jabbapylib.mail.gmail_send import mail_html
from jabbapylib.web.web import get_page, html_to_text
import sys

URL = 'http://www.easychair.org/'
USERNAME = "..."
PASSWORD = "..."
sender = {
    'gmail_user': USERNAME,
    'gmail_name': "PyChecker",
    'gmail_pwd': PASSWORD,
STOP = False

def is_down(url):
    Check if the site is down.

    Return True if it's down. Otherwise, return False.
    html = get_page(url)
    text = " ".join(html_to_text(html).split())
    return "We are sorry for any inconveniences caused." in text

def job():
    global STOP

    if is_down(URL):
        print("The site is still down.")
        print("The site is up.")
        mail_html(sender, "TO@gmail.com",
            "EasyChair is up!",
            "Send your paper: <a href='https://www.easychair.org'>EasyChair</a>.")
        print("E-mail notification was sent.")
        STOP = True

def main():


    while not STOP:
        sys.stdout.write('.'); sys.stdout.flush()


if __name__ == "__main__":
Categories: python Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: