Commit 507267b5 by Nagy Gergő

Formating fixed.

parent ed351d66
import json, requests import requests
class GraphiteHandler: class GraphiteHandler:
def __init__(self, server_name = "localhost", server_port = "8080"): def __init__(self, server_name="localhost", server_port="8080"):
self.__server_name = server_name self.__server_name = server_name
self.__server_port = server_port self.__server_port = server_port
self.__queries = [] self.__queries = []
...@@ -34,11 +35,12 @@ class GraphiteHandler: ...@@ -34,11 +35,12 @@ class GraphiteHandler:
Important: After sending queries to the server the fifo will lost its Important: After sending queries to the server the fifo will lost its
content. content.
""" """
url_base = "http://%s:%s/render?" % (self.__server_name, self.__server_port) url_base = "http://%s:%s/render?" % (self.__server_name,
self.__server_port)
for query in self.__queries: for query in self.__queries:
response = requests.get(url_base + query.getGenerated()) response = requests.get(url_base + query.getGenerated())
if query.getFormat() is "json": if query.getFormat() is "json":
self.__responses.append(response.json()[0]) #DICT self.__responses.append(response.json()) # DICT
else: else:
self.__responses.append(response) self.__responses.append(response)
self.cleanUpQueries() self.cleanUpQueries()
...@@ -52,6 +54,7 @@ class GraphiteHandler: ...@@ -52,6 +54,7 @@ class GraphiteHandler:
except: except:
print("There is no more responses.") print("There is no more responses.")
class Query: class Query:
def __init__(self): def __init__(self):
...@@ -90,7 +93,7 @@ class Query: ...@@ -90,7 +93,7 @@ class Query:
""" """
Function for setting the time you want to get the reports from. Function for setting the time you want to get the reports from.
""" """
if(len(year)>4 or len(year)<2): if(len(year) > 4 or len(year) < 2):
raise raise
self.__start = hour + ":" + minute + "_" + year + month + day self.__start = hour + ":" + minute + "_" + year + month + day
...@@ -98,7 +101,8 @@ class Query: ...@@ -98,7 +101,8 @@ class Query:
""" """
Function for setting the time you want to get the reports from. Function for setting the time you want to get the reports from.
""" """
if scale not in ["years", "months", "days", "hours", "minutes", "seconds"]: if (scale not in ["years",
"months", "days", "hours", "minutes", "seconds"]):
raise raise
self.__start = "-" + str(value) + scale self.__start = "-" + str(value) + scale
...@@ -109,7 +113,7 @@ class Query: ...@@ -109,7 +113,7 @@ class Query:
""" """
Function for setting the time until you want to get the reports from. Function for setting the time until you want to get the reports from.
""" """
if(len(year)>4 or len(year)<2): if(len(year) > 4 or len(year) < 2):
raise raise
self.__end = hour + ":" + minute + "_" + year + month + day self.__end = hour + ":" + minute + "_" + year + month + day
...@@ -117,7 +121,8 @@ class Query: ...@@ -117,7 +121,8 @@ class Query:
""" """
Function for setting the time until you want to get the reports from. Function for setting the time until you want to get the reports from.
""" """
if scale not in ["years", "months", "days", "hours", "minutes", "seconds"]: if (scale not in ["years",
"months", "days", "hours", "minutes", "seconds"]):
raise raise
self.__end = "-" + str(value) + scale self.__end = "-" + str(value) + scale
...@@ -160,5 +165,3 @@ class Query: ...@@ -160,5 +165,3 @@ class Query:
if len(self.__generated) is 0: if len(self.__generated) is 0:
raise raise
return self.__generated return self.__generated
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment