~didrocks/unity/altf10

« back to all changes in this revision

Viewing changes to grackle/client.py

  • Committer: Curtis Hovey
  • Date: 2012-02-14 21:55:15 UTC
  • Revision ID: curtis.hovey@canonical.com-20120214215515-vu1zn9n58ov659es
Added basic handling of date_range.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
    urlencode,
7
7
)
8
8
 
9
 
from grackle.error import (
10
 
    UnparsableDateRange,
11
 
    UnsupportedDisplayType,
12
 
    UnsupportedOrder,
 
9
 
 
10
class UnparsableDateRange(Exception):
 
11
    """The date_range was not in the format of 2012-01-01..2012-01-31."""
 
12
 
 
13
 
 
14
class UnsupportedDisplayType(Exception):
 
15
    """Raised when an Unsupported display_type is requested."""
 
16
 
 
17
 
 
18
class UnsupportedOrder(Exception):
 
19
    """Raised when an Unsupported order is requested."""
 
20
 
 
21
 
 
22
SUPPORTED_DISPLAY_TYPES = (
 
23
    'all',
 
24
    'text-only',
 
25
    'headers-only',
13
26
    )
14
27
 
15
28
 
124
137
                raise UnsupportedOrder
125
138
            elif response.reason == UnsupportedDisplayType.__doc__:
126
139
                raise UnsupportedDisplayType
127
 
            elif response.reason == UnparsableDateRange.__doc__:
128
 
                raise UnparsableDateRange
129
140
            else:
130
141
                raise ValueError('Bad request')
131
142
        data = response.read()