Line | |
---|
1 | import re
|
---|
2 |
|
---|
3 | from ....builtins import *
|
---|
4 |
|
---|
5 | from ...exceptions import *
|
---|
6 | from ...expressions import *
|
---|
7 | from ...streams import *
|
---|
8 |
|
---|
9 | re_status = re.compile('^Checking for (.*) \.\.(.*)$')
|
---|
10 |
|
---|
11 | ##
|
---|
12 | ## puredisk status has one record per-stream
|
---|
13 | ##
|
---|
14 | def stream(stream, format='puredisk status'):
|
---|
15 |
|
---|
16 | if format in ['puredisk status']:
|
---|
17 | return SingleRecordStream(stream)
|
---|
18 | else:
|
---|
19 | raise ParseError, 'Unknown format %s' % (format)
|
---|
20 |
|
---|
21 |
|
---|
22 | ##
|
---|
23 | ## Parse a puredisk status record
|
---|
24 | ##
|
---|
25 | ## /etc/init.d/puredisk status
|
---|
26 | ##
|
---|
27 | def parse(record, format='puredisk status', version=None, tz=None):
|
---|
28 |
|
---|
29 | status = ExtendedDict()
|
---|
30 |
|
---|
31 | if format in ['puredisk status']:
|
---|
32 |
|
---|
33 | try:
|
---|
34 |
|
---|
35 | for line in record:
|
---|
36 |
|
---|
37 | match = re_status.match(line)
|
---|
38 |
|
---|
39 | if match:
|
---|
40 |
|
---|
41 | service = match.group(1)
|
---|
42 | state = match.group(2)
|
---|
43 |
|
---|
44 | status[service] = state
|
---|
45 |
|
---|
46 | return status
|
---|
47 |
|
---|
48 | except Exception, e:
|
---|
49 |
|
---|
50 | raise ParseError, e
|
---|
51 |
|
---|
52 | else:
|
---|
53 |
|
---|
54 | raise ParseError, 'Unknown format %s' % (format)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.