bug fixes and check plugin exists

This commit is contained in:
Volkan Şahin 2016-03-25 17:56:15 +02:00
parent cea2afccc6
commit fedc9cbd2c
3 changed files with 18 additions and 6 deletions

View file

@ -111,6 +111,8 @@ class AhenkDbService(object):
row = self.cursor.fetchone() row = self.cursor.fetchone()
if row is not None: if row is not None:
return row[0] return row[0]
else:
return None
except Exception as e: except Exception as e:
raise raise
else: else:

View file

@ -97,7 +97,7 @@ class ExecutionManager(object):
default_file_path = self.config_manager.get('CONNECTION', 'receiveFileParam') default_file_path = self.config_manager.get('CONNECTION', 'receiveFileParam')
j = json.loads(arg) j = json.loads(arg)
# msg_id =str(j['id']).lower() # msg_id =str(j['id']).lower()
target_file_path = str(j['filepath']).lower() target_file_path = str(j['filePath']).lower()
file_name = str(j['filename']).lower() file_name = str(j['filename']).lower()
self.logger.debug('[ExecutionManager] ' + file_name + ' will be moved to ' + target_file_path) self.logger.debug('[ExecutionManager] ' + file_name + ' will be moved to ' + target_file_path)
shutil.move(default_file_path + file_name, target_file_path + file_name) shutil.move(default_file_path + file_name, target_file_path + file_name)
@ -105,7 +105,7 @@ class ExecutionManager(object):
def execute_script(self, arg): def execute_script(self, arg):
j = json.loads(arg) j = json.loads(arg)
# msg_id =str(j['id']).lower() # msg_id =str(j['id']).lower()
file_path = str(j['filepath']).lower() file_path = str(j['filePath']).lower()
time_stamp = str(j['timestamp']).lower() time_stamp = str(j['timestamp']).lower()
self.logger.debug('[ExecutionManager] Making executable file (%s) for execution' % file_path) self.logger.debug('[ExecutionManager] Making executable file (%s) for execution' % file_path)
st = os.stat(file_path) st = os.stat(file_path)
@ -116,7 +116,7 @@ class ExecutionManager(object):
def request_file(self, arg): def request_file(self, arg):
j = json.loads(arg) j = json.loads(arg)
# msg_id =str(j['id']).lower() # msg_id =str(j['id']).lower()
file_path = str(j['filepath']).lower() file_path = str(j['filePath']).lower()
time_stamp = str(j['timestamp']).lower() time_stamp = str(j['timestamp']).lower()
self.logger.debug('[ExecutionManager] Requested file is ' + file_path) self.logger.debug('[ExecutionManager] Requested file is ' + file_path)
self.messager.send_file(file_path) self.messager.send_file(file_path)

View file

@ -17,10 +17,12 @@ class PluginManager(object):
super(PluginManager, self).__init__() super(PluginManager, self).__init__()
self.scope = Scope.getInstance() self.scope = Scope.getInstance()
self.configManager = self.scope.getConfigurationManager() self.configManager = self.scope.getConfigurationManager()
self.db_service = self.scope.getDbService()
self.plugins = [] self.plugins = []
self.pluginQueueDict = dict() self.pluginQueueDict = dict()
self.logger = self.scope.getLogger() self.logger = self.scope.getLogger()
#TODO version?
def loadPlugins(self): def loadPlugins(self):
self.plugins = [] self.plugins = []
possibleplugins = os.listdir(self.configManager.get("PLUGIN", "pluginFolderPath")) possibleplugins = os.listdir(self.configManager.get("PLUGIN", "pluginFolderPath"))
@ -64,9 +66,17 @@ class PluginManager(object):
# Not implemented yet # Not implemented yet
pass pass
def checkPluginExists(self, pluginName): def checkPluginExists(self, plugin_name, version=None):
# Not implemented yet
pass criteria = ' name=\''+plugin_name+'\''
if version is not None:
criteria += ' and version=\'' + str(version) + '\''
result = self.db_service.select('plugin', 'name', criteria)
if result is None:
return False
else:
return True
def reloadSinglePlugin(self, pluginName): def reloadSinglePlugin(self, pluginName):
# Not implemented yet # Not implemented yet