Skip to content

Commit 965b4e7

Browse files
committed
part2 python flake8 fix
Signed-off-by: hwassman <[email protected]>
1 parent ffaeb93 commit 965b4e7

File tree

1 file changed

+8
-29
lines changed

1 file changed

+8
-29
lines changed

source/prometheus.py

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@
2323
import cherrypy
2424
import copy
2525
import json
26-
from messages import ERR, MSG
26+
from messages import MSG
2727
from typing import Optional
2828
from cherrypy.process.plugins import Monitor
29-
from time import time
3029
from collector import SensorCollector, QueryPolicy
3130
from utils import execution_time
3231

@@ -56,7 +55,7 @@ def qh(self):
5655
def TOPO(self):
5756
return self.__md.metaData
5857

59-
def format_response(self, data)-> [str]:
58+
def format_response(self, data) -> [str]:
6059
resp = []
6160
for name, metric in data.items():
6261
header = metric.str_descfmt()
@@ -127,33 +126,14 @@ def build_collector(self, sensor) -> SensorCollector :
127126
attrs = {'sensor': sensor, 'period': period, 'nsamples': 1}
128127
request = QueryPolicy(**attrs)
129128
collector = SensorCollector(sensor, period, self.logger, request)
130-
# collector.cache = True
131-
# else:
132-
# ts = calendar.timegm(time.gmtime()) - 15
133-
# ts = int(round(time.time() * 1000))
134-
# ts=int(timer()*1000)
135-
136-
# ts=int(time()*1000)
137-
# ts1 = ts-1000
138-
# self.logger.trace("ts:{0}, ts1:{1}".format(str(ts),str(ts1)))
139-
# qstart = str(int(int(str(ts1)) / 1000))
140-
# attrs = {'sensor': sensor, 'period': period, 'start': qstart}
141-
# request = QueryPolicy(**attrs)
142-
# collector = SensorCollector(sensor, period, self.logger, request)
143-
144-
self.logger.debug(f'request instance {str(request.__dict__)}')
145-
self.logger.debug(f'Created Collector instance {str(collector.__dict__)}')
129+
130+
self.logger.trace(f'request instance {str(request.__dict__)}')
131+
self.logger.trace(f'Created Collector instance {str(collector.__dict__)}')
146132
return collector
147133

148134
def GET(self, **params):
149-
'''Handle partial URLs such as /api/suggest?q=cpu_&type=metrics
150-
where type is one of metrics, tagk or tagv
151-
or
152-
Handle /api/search/lookup/m=cpu_idle{node=*}
153-
where m is the metric and optional term { tagk = tagv } qualifies the lookup.
154-
For more details please check openTSDB API (version 2.2 and higher) documentation for
155-
/api/lookup
156-
/api/search/lookup
135+
'''Handle partial URLs such as /metrics_cpu
136+
TODO: add more explanation
157137
'''
158138
resp = []
159139

@@ -163,7 +143,7 @@ def GET(self, **params):
163143

164144
# /update
165145
if 'update' in cherrypy.request.script_name:
166-
#cherrypy.response.headers['Content-Type'] = 'application/json'
146+
# cherrypy.response.headers['Content-Type'] = 'application/json'
167147
resp = self.md.update()
168148

169149
# /metrics_cpu
@@ -207,7 +187,6 @@ def GET(self, **params):
207187
cherrypy.response.headers['Content-Type'] = 'text/plain'
208188
resString = '\n'.join(resp) + '\n'
209189
return resString
210-
#return bytes(resString, 'utf-8')
211190

212191
# /metrics_gpfs_fileset
213192
elif 'metrics_gpfs_fileset' in cherrypy.request.script_name:

0 commit comments

Comments
 (0)