~launchpad-results/launchpad-results/trunk

« back to all changes in this revision

Viewing changes to lib/lpresults/scripts/application.py

  • Committer: Marc Tardif
  • Date: 2012-03-21 22:32:04 UTC
  • Revision ID: marc.tardif@canonical.com-20120321223204-8g7mvzzwmh8ifbrt
Added support for getting systems from a person (LP #899361)

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
import sys
12
12
 
 
13
from httplib import BadStatusLine
13
14
from optparse import (
14
15
    OptionGroup,
15
16
    OptionParser,
62
63
        """
63
64
        try:
64
65
            return urlopen(url)
65
 
        except URLError, error:
 
66
        except (URLError, BadStatusLine), error:
66
67
            # 404 errors indicate a data inconsistency: more than one
67
68
            # try to open the URL is pointless.
68
69
            #
72
73
 
73
74
            # HTTPErrors with a 5xx error code ("server problem") are
74
75
            # a reason to retry the access again, as well as generic,
75
 
            # non-HTTP, URLErrors like "connection refused".
 
76
            # non-HTTP, URLErrors like "connection refused" or
 
77
            # BadStatusLine like "connection closed".
76
78
            if (isinstance(error, HTTPError)
77
79
                and 500 <= error.code <= 599
78
80
                or isinstance(error, URLError) and
79
 
                    not isinstance(error, HTTPError)):
 
81
                    not isinstance(error, HTTPError)
 
82
                or isinstance(error, BadStatusLine)):
80
83
                raise ApplicationError(str(error))
81
84
 
82
85
            else: