Commit ec91e24f by Gregory Nagy

pep8 conventions

parent 3faa2b8f
import ConfigParser as configparser
import sys
if sys.version_info < (3, 0):
import ConfigParser as configparser
else:
import configparser
def importConf(path_to_file):
def import_conf(path_to_file):
config = configparser.RawConfigParser(allow_no_value=False)
try:
config.read(path_to_file)
params = {}
metrics = {}
params["debugMode"] = config.get("Client", "Debug")
##
## Metrics
##
metrics["cpu.usage"] = int(config.get("Metrics", "cpuUsage"))
metrics["cpu.times"] = int(config.get("Metrics", "cpuTimes"))
metrics["memory.usage"] = int(config.get("Metrics", "memoryUsage"))
......@@ -16,17 +23,23 @@ def importConf(path_to_file):
metrics["system.boot_time"] = int(config.get("Metrics",
"systemBootTime"))
metrics["network"] = int(config.get("Metrics", "dataTraffic"))
##
## Params
##
params["kvmCpuUsage"] = int(config.get("KVM", "cpuUsage"))
params["kvmMemoryUsage"] = int(config.get("KVM", "memoryUsage"))
params["kvmNetworkUsage"] = int(config.get("KVM", "networkUsage"))
except configparser.NoSectionError:
print("Config file contains error! Reason: Missing section.")
print("[ERROR] Config file contains error! "
"Reason: Missing section.")
raise
except configparser.ParsingError:
print("Config file contains error! Reason: Cannot parse.")
print("[ERROR] Config file contains error! "
"Reason: Cannot parse.")
raise
except configparser.MissingSectionHeaderError:
print("Config file contains error! Reason: Missing section-header.")
print("[ERROR] Config file contains error! "
"Reason: Missing section-header.")
raise
return params, metrics
......@@ -18,20 +18,19 @@ class collectables:
}
@staticmethod
def listKeys():
def list_keys():
return list(collectables.__collectables.keys())
@staticmethod
def listMetricsToKey(key):
def list_metrics_to_key(key):
return collectables.__collectables[key]
@staticmethod
def listMetricsNameToKey(key):
def list_metrics_name_to_key(key):
return [x.name for x in collectables.__collectables[key]]
@staticmethod
def provide(requests=[]):
#valid_keys = collectables.listKeys()
reqs = []
for requests, value in requests.items():
if value > 0:
......@@ -44,4 +43,4 @@ class collectables:
@staticmethod
def provideAll():
return collectables.provide(collectables.listKeys())
return collectables.provide(collectables.list_keys())
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