+ def error(self, msg, exception=""):
+ if exception != "":
+ exception = " " + str(exception).replace("\n"," ")
+ sys.stderr.write(str(msg)+exception+"\n")
+ sys.stderr.flush()
+
+ def check(self):
+ # TODO notify about not overriden function
+ self.error("Where is your check()?")
+ return False
+
+ def create(self):
+ # TODO notify about not overriden function
+ self.error("Where is your create()?")
+ return False
+
+ def update(self):
+ # TODO notify about not overriden function
+ self.error("Where is your update()?")
+ return False
+
+
+class Service(BaseService):
+ def __init__(self,configuration=None,update_every=3,priority=90000,retries=2):
+ super().__init__(*args,**kwargs)
+ self.configuration = self._parse_config(configuration)
+ self.connection = None
+ self.defs = None
+
+ def _parse_config(configuration):
+ # parse configuration to collect data from mysql server
+ if 'name' not in configuration:
+ configuration['name'] = 'local'
+ if 'user' not in configuration:
+ configuration['user'] = 'root'
+ if 'password' not in configuration:
+ configuration['password'] = ''
+ if 'my.cnf' in configuration:
+ configuration['socket'] = ''
+ configuration['host'] = ''
+ configuration['port'] = 0
+ elif 'socket' in configuration:
+ configuration['my.cnf'] = ''
+ configuration['host'] = ''
+ configuration['port'] = 0
+ elif 'host' in configuration:
+ configuration['my.cnf'] = ''
+ configuration['socket'] = ''
+ if 'port' in configuration:
+ configuration['port'] = int(configuration['port'])
+ else:
+ configuration['port'] = 3306
+
+ return configuration