82
break
83
result = opened.readline()
84
return result.decode()
85
-
86
-
87
-class OldVersionCompatibility:
88
-
89
- def __init__(self):
90
- self._data_stream = str()
91
-
92
- def begin(self, type_id, microseconds=0):
93
- """
94
- :param type_id: <str>
95
- :param microseconds: <str> or <int>: must be a digit
96
- :return:
97
- """
98
- self._data_stream += CHART_BEGIN.format(type_id, microseconds)
99
-
100
- def set(self, dim_id, value):
101
- """
102
- :param dim_id: <str>
103
- :param value: <int> or <str>: must be a digit
104
- :return:
105
- """
106
- self._data_stream += DIMENSION_SET.format(dim_id, value)
107
-
108
- def end(self):
109
- self._data_stream += 'END\n'
110
-
111
- def chart(self, type_id, name='', title='', units='', family='', category='', chart_type='line',
112
- priority='', update_every=''):
113
- """
114
- :param type_id: <str>
115
- :param name: <str>
116
- :param title: <str>
117
- :param units: <str>
118
- :param family: <str>
119
- :param category: <str>
120
- :param chart_type: <str>
121
- :param priority: <str> or <int>
122
- :param update_every: <str> or <int>
123
- :return:
124
- """
125
- self._data_stream += CHART_CREATE.format(type_id, name, title, units,
126
- family, category, chart_type,
127
- priority, update_every)
128
-
129
- def dimension(self, dim_id, name=None, algorithm="absolute", multiplier=1, divisor=1, hidden=False):
130
- """
131
- :param dim_id: <str>
132
- :param name: <str> or None
133
- :param algorithm: <str>
134
- :param multiplier: <str> or <int>: must be a digit
135
- :param divisor: <str> or <int>: must be a digit
136
- :param hidden: <str>: literally "hidden" or ""
137
- :return:
138
- """
139
- self._data_stream += DIMENSION_CREATE.format(dim_id, name or dim_id, algorithm,
140
- multiplier, divisor, hidden or str())
141
-
142
- @on_try_except_finally(on_except=(exit, 1))
143
- def commit(self):
144
- print(self._data_stream)
145
- self._data_stream = str()