import requests

def check_links(args_obj, parser):
    print("")
    print("Checking links")
    print("########################")
    print("Not implemented yet.")
    print("This is supposed to check all links in the system.")
    print("########################")

@@ -1,268 +1,1711 @@
-import requests%0A%0Adef check_links(args_obj, parser):%0A    print(%22%22)%0A    print(%22Checking links%22)%0A    print(%22########################%22)%0A    print(%22Not implemented yet.%22)%0A    print(%22This is supposed to check all links in the system.%22)%0A    print(%22########################
+from __future__ import print_function%0Aimport re%0Aimport requests%0Afrom lxml.html import parse%0Afrom requests.exceptions import ConnectionError%0A%0Adef is_root_link(link):%0A    pattern = re.compile(%22%5E/$%22)%0A    return pattern.match(link)%0A%0Adef is_mailto_link(link):%0A    pattern = re.compile(%22%5Emailto:.*%22)%0A    return pattern.match(link)%0A%0Adef is_internal_link(link):%0A    pattern = re.compile(%22%5E/.*%22)%0A    return pattern.match(link)%0A%0Adef get_links(doc):%0A    return filter(%0A        lambda x: not (%0A            is_root_link(x)%0A            or is_mailto_link(x))%0A        , map(lambda y: y.get(%22href%22)%0A              , doc.cssselect(%22a%22)))%0A%0Adef verify_link(link):%0A    try:%0A        result = requests.get(link, timeout=20)%0A        if result.status_code == 200:%0A            print(link+%22 ==%3E OK%22)%0A        else:%0A            print(%22ERROR: link %60%22+link+%22%60 failed with status %22%0A                  , result.status_code)%0A    except ConnectionError as ex:%0A        print(%22ERROR: %22, link, ex)%0A%0Adef check_page(host, start_url):%0A    print(%22%22)%0A    print(%22Checking links in page %60%22+start_url+%22%60%22)%0A    doc = parse(start_url).getroot()%0A    links = get_links(doc)%0A    internal_links = filter(is_internal_link, links)%0A    external_links = filter(lambda x: not is_internal_link(x), links)%0A    external_links.append(%22http://somenon-existentsite.brr%22)%0A    for link in internal_links:%0A        verify_link(host+link)%0A%0A    for link in external_links:%0A        verify_link(link)%0A%0Adef check_links(args_obj, parser):%0A    print(%22%22)%0A    print(%22Checking links%22)%0A    host = args_obj.host%0A%0A    # Check the home page%0A    check_page(host, host)%0A%0A    # Check traits page%0A    check_page(%0A        host,%0A        host+%22/show_trait?trait_id=1435395_s_at&dataset=HC_M2_0606_P
 %22)%0A

Add tests to check links.