From 07f1e21b570604fc8f04f2bf881f8b7a3b1ce563 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20=C5=9Eahin?= Date: Tue, 18 Oct 2016 18:10:52 +0300 Subject: [PATCH] code formatted --- opt/ahenk/base/database/ahenk_db_service.py | 41 +++++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/opt/ahenk/base/database/ahenk_db_service.py b/opt/ahenk/base/database/ahenk_db_service.py index bb4758b..4d4c14d 100644 --- a/opt/ahenk/base/database/ahenk_db_service.py +++ b/opt/ahenk/base/database/ahenk_db_service.py @@ -28,13 +28,29 @@ class AhenkDbService(object): def initialize_table(self): - self.check_and_create_table('task', ['id INTEGER', 'create_date TEXT', 'modify_date TEXT', 'command_cls_id TEXT', 'parameter_map BLOB', 'deleted INTEGER', 'plugin TEXT', 'cron_expr TEXT','file_server TEXT']) - self.check_and_create_table('policy', ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'type TEXT', 'version TEXT', 'name TEXT', 'execution_id TEXT']) - self.check_and_create_table('profile', ['id INTEGER', 'create_date TEXT', 'label TEXT', 'description TEXT', 'overridable INTEGER', 'active TEXT', 'deleted TEXT', 'profile_data TEXT', 'modify_date TEXT', 'plugin TEXT']) - self.check_and_create_table('plugin', ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'active TEXT', 'create_date TEXT', 'deleted TEXT', 'description TEXT', 'machine_oriented TEXT', 'modify_date TEXT', 'name TEXT', 'policy_plugin TEXT', 'user_oriented TEXT', 'version TEXT', 'task_plugin TEXT', 'x_based TEXT']) - self.check_and_create_table('registration', ['jid TEXT', 'password TEXT', 'registered INTEGER', 'dn TEXT', 'params TEXT', 'timestamp TEXT']) - self.check_and_create_table('contract', ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'content BLOB', 'title TEXT', 'timestamp TEXT']) - self.check_and_create_table('agreement', ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'contract_id TEXT', 'username TEXT', 'timestamp TEXT', 'choice TEXT']) + self.check_and_create_table('task', + ['id INTEGER', 'create_date TEXT', 'modify_date TEXT', 'command_cls_id TEXT', + 'parameter_map BLOB', 'deleted INTEGER', 'plugin TEXT', 'cron_expr TEXT', + 'file_server TEXT']) + self.check_and_create_table('policy', + ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'type TEXT', 'version TEXT', 'name TEXT', + 'execution_id TEXT']) + self.check_and_create_table('profile', ['id INTEGER', 'create_date TEXT', 'label TEXT', 'description TEXT', + 'overridable INTEGER', 'active TEXT', 'deleted TEXT', + 'profile_data TEXT', 'modify_date TEXT', 'plugin TEXT']) + self.check_and_create_table('plugin', + ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'active TEXT', 'create_date TEXT', + 'deleted TEXT', 'description TEXT', 'machine_oriented TEXT', 'modify_date TEXT', + 'name TEXT', 'policy_plugin TEXT', 'user_oriented TEXT', 'version TEXT', + 'task_plugin TEXT', 'x_based TEXT']) + self.check_and_create_table('registration', + ['jid TEXT', 'password TEXT', 'registered INTEGER', 'dn TEXT', 'params TEXT', + 'timestamp TEXT']) + self.check_and_create_table('contract', ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'content BLOB', 'title TEXT', + 'timestamp TEXT']) + self.check_and_create_table('agreement', + ['id INTEGER PRIMARY KEY AUTOINCREMENT', 'contract_id TEXT', 'username TEXT', + 'timestamp TEXT', 'choice TEXT']) self.check_and_create_table('session', ['username TEXT', 'display TEXT', 'desktop TEXT', 'timestamp TEXT']) def get_cols(self, table_name): @@ -44,6 +60,14 @@ class AhenkDbService(object): return ['content', 'title', 'timestamp'] elif table_name == 'session': return ['username', 'display', 'desktop', 'timestamp'] + elif table_name == 'task': + return ['id', 'create_date', 'modify_date', 'command_cls_id', 'parameter_map', 'deleted', 'plugin', + 'cron_expr', 'file_server'] + elif table_name == 'plugin': + return ['id', 'active', 'create_date', 'deleted', 'description', 'machine_oriented', 'modify_date', 'name', + 'policy_plugin', 'user_oriented', 'version', 'task_plugin', 'x_based'] + else: + return None def connect(self): try: @@ -94,7 +118,8 @@ class AhenkDbService(object): self.logger.warning('Could not update table cursor is None! Table Name : {0}'.format(str(table_name))) return None except Exception as e: - self.logger.error('Updating table error ! Table Name : {0} Error Mesage: {1}'.format(str(table_name),str(e))) + self.logger.error( + 'Updating table error ! Table Name : {0} Error Mesage: {1}'.format(str(table_name), str(e))) finally: self.lock.release()