This file is indexed.

/usr/bin/launchpad-service-status is in python-launchpadlib-toolkit 0.5.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python

# Script to check if launchpad is up and usable.
#
# Since this script does some http queries it is a bit slow.  The intent
# is to run it periodically to 'test' launchpad and cache the result
# locally; cronjobs can then check this cached status value to see if
# launchpad is available, and if not, bail out and not bother trying to
# run.

import re
import sys
import feedparser
from datetime import ( datetime, timedelta )
import launchpadlib
from launchpadlib.launchpad import Launchpad

consumer='lpltk'
service_root='production'

def expected_outage():
    """Returns tuple of (start, stop) time for the current or next expected outage"""

    (expected_start, expected_end) = (None, None)

    d = feedparser.parse('http://blog.launchpad.net/category/notifications/feed')
    latest_entry = d['entries'][0]
    notice_html = latest_entry['content'][0]['value']

    date_format = ' %H.%M UTC %d of %B %Y'

    m = re.search("Starts:.*>(.*)<", notice_html)
    if m:
        raw_text = m.group(1)
        text = re.sub(r'(\d+)(?:st|nd|rd|th) ', r'\1 ', raw_text)
        expected_start = datetime.strptime(text, date_format)

    m = re.search('Expected.*back.*by.*>(.*)<', notice_html)
    if m:
        raw_text = m.group(1)
        text = re.sub(r'(\d+)(?:st|nd|rd|th) ', r'\1 ', raw_text)
        expected_end = datetime.strptime(text, date_format)

    return (expected_start, expected_end)


(outage_start, outage_end) = expected_outage()

# Are we in the middle of an expected outage?
if datetime.now() > outage_start and datetime.now() < outage_end:
    print 'OFFLINE EXPECTED'
    sys.exit(3)

# Will we be offline shortly?
pending_offline_time = timedelta(hours=2)
if datetime.now() + pending_offline_time > outage_start:
    print 'PENDING OFFLINE'
    sys.exit(2)

# Can we at least reach launchpad's api service in minimal read-only mode?
try:
    lp = Launchpad.login_anonymously(consumer, service_root) # Need >= 1.5.1
except:
    print 'OFFLINE UNKNOWN'
    sys.exit(9)

# See if we can access read-write too
try:
    lp = Launchpad.login_with(consumer, service_root)
    print 'UP READWRITE'
except:
    print 'UP READONLY'
    sys.exit(1)

sys.exit(0)