Statistics
| Branch: | Tag: | Revision:

root / docs / source / handling.rst @ eb4ed8c6

History | View | Annotate | Download (3.2 kB)

1
Raw Text vs Structured data
2
===========================
3

    
4
This section covers the differences between raw text output from the Alcatel IOO and how the data can be structured to become usable
5

    
6
Raw Text output
7
---------------
8

    
9
By default the Alcatel IOO returns data in raw text format. Though the text is delimited is practically impossible to do anything with it.
10

    
11
For example::
12

    
13
	The command:
14
	
15
	LIST_PM_DATA_REQ[]
16
	
17
	returns:
18
	
19
	PM_DATA_NOTIF[notificationType=pmList|friendlyName=elementNAme|neLocationName=
20
	|periodType=15{pmPoint=elementName/r01sr1sl08/port#01-OCHrsTMi-PMTR15{period=2012060501
21
	|LOD=0{BBE=0|ES=0|SES=0|NEUAS=0|UAS=0|BBU=0|SUS=0|BEC=0|BER=0|QF=0|SCS=0|US=0|CS=0|FEBBE=0|FEES=0|FESES=0|FEUAS=0}
22
	.....
23
	
24
which provides info about the Performance Monitoring points but requires quite some parsing to become usable.
25

    
26
If, although, someone wants to get the raw text output, it is still possible by setting the **parse** argument to *False* in the corresponding methods:
27

    
28
* :meth:`~iooclient.eos_pmd.eosPmd.list_pm_point`
29
* :meth:`~iooclient.eos_pmd.eosPmd.list_pm_data`
30
* :meth:`~iooclient.eos_ned.eosNed.list_ne_dir`
31

    
32
depending on what the user wants to acquire
33

    
34
To tackle with this, the Python `pyparsing <http://http://pyparsing.wikispaces.com//>`_, module was used. 
35

    
36
Structured Data
37
---------------
38

    
39
The pyparsing module provides a way to "build" a grammar that matches the output from the Alcatel IOO. Once the text is parsed through the pyparsing module,
40
it becomes structured in a Python list of lists of lists (and probably of dicts) data structure. At this point the data is iterable but yet, it is hard to use it.
41

    
42
The final step is to dictionarize this data structure.
43
Now the data is iterable and the values accessible via dictionary keys (example from :ref:`pmd-label`)::
44

    
45
    from iooclient.eos_pmd import *
46

    
47
    with eosPmd('1.2.3.4', 20006, 'pass') as pmd:
48
        pmd.list_pm_points()
49
    
50
    will give a list of dicts of lists of dicts...:
51
    
52
    [
53
        {'friendlyName': 'ma1eie',
54
       'neLocationName': None,
55
       'notificationType': 'pmList',
56
       'periodType': '15',
57
       'pmpoints': [{'periods': [{'LOD': '0 ',
58
                             'counters': [{'BBE': '0'},
59
                                          {'BBU': '0'},
60
                                          {'BEC': '0'},
61
                                          {'BER': '0'},
62
                                          {'CS': '0'},
63
                                          {'ES': '0'},
64
                                          {'FEBBE': '0'},
65
                                          {'FEES': '0'},
66
                                          {'FESES': '0'},
67
                                          {'FEUAS': '0'},
68
                                          {'NEUAS': '0'},
69
                                          {'QF': '0'},
70
                                          {'SCS': '0'},
71
                                          {'SES': '0'},
72
                                          {'SUS': '0'},
73
                                          {'UAS': '0'},
74
                                          {'US': '0'}],
75
       'period': '2012061501'},
76
        {....},
77
        {....},...
78
    ] 
79

    
80
As list of dictionaries the data can be iterated and fed into applications (eg. Django).