some fixing about logs

This commit is contained in:
Volkan Şahin 2016-08-02 18:16:53 +03:00
parent a5c864d33f
commit 23335f5d99
2 changed files with 14 additions and 7 deletions

View file

@ -262,10 +262,12 @@ class AhenkDeamon(BaseDaemon):
db_service = scope.getDbService() db_service = scope.getDbService()
execute_manager = scope.getExecutionManager() execute_manager = scope.getExecutionManager()
event=''
try: try:
json_data = json.loads(Commander().get_event()) event=Commander().get_event()
json_data = json.loads(event)
except Exception as e: except Exception as e:
self.logger.error('[AhenkDeamon] A problem occurred while loading json. Check json format! Error Message: {0}'.format(str(e))) self.logger.error('[AhenkDeamon] A problem occurred while loading json. Check json format! Error Message: {0}.Event={1} '.format(str(e),str(event)))
return return
if json_data is not None: if json_data is not None:

View file

@ -79,7 +79,8 @@ class Commander(object):
response['contentType'] = self.get_relevant_type(str(params[5])) response['contentType'] = self.get_relevant_type(str(params[5]))
response['responseData'] = Util.read_file(str(params[5]), 'rb') response['responseData'] = Util.read_file(str(params[5]), 'rb')
else: else:
print('Wrong or missing parameter. Usage: send -t <task_id> -m|-f <message_content>|<file_path>') print(
'Wrong or missing parameter. Usage: send -t <task_id> -m|-f <message_content>|<file_path>')
return None return None
if len(params) > 6: if len(params) > 6:
@ -90,7 +91,8 @@ class Commander(object):
elif params[6] == '-s': elif params[6] == '-s':
response['responseCode'] = MessageCode.TASK_PROCESSED.value response['responseCode'] = MessageCode.TASK_PROCESSED.value
else: else:
print('Wrong or missing parameter.(-e|-s|-w parameters are optional) Usage: send -t <task_id> -m|-f <message_content>|<file_path> -e|-s|-w') print(
'Wrong or missing parameter.(-e|-s|-w parameters are optional) Usage: send -t <task_id> -m|-f <message_content>|<file_path> -e|-s|-w')
return None return None
elif len(params) > 7 and params[2] == '-p': elif len(params) > 7 and params[2] == '-p':
@ -109,7 +111,8 @@ class Commander(object):
response['contentType'] = self.get_relevant_type(str(params[7])) response['contentType'] = self.get_relevant_type(str(params[7]))
response['responseData'] = Util.read_file(str(params[7]), 'rb') response['responseData'] = Util.read_file(str(params[7]), 'rb')
else: else:
print('Wrong or missing parameter. Usage: send -p <policy_version> -c <command_execution_id> -m|-f <message_content>|<file_path>') print(
'Wrong or missing parameter. Usage: send -p <policy_version> -c <command_execution_id> -m|-f <message_content>|<file_path>')
return None return None
if len(params) > 8: if len(params) > 8:
@ -120,11 +123,13 @@ class Commander(object):
elif params[8] == '-s': elif params[8] == '-s':
response['responseCode'] = MessageCode.POLICY_PROCESSED.value response['responseCode'] = MessageCode.POLICY_PROCESSED.value
else: else:
print('Wrong or missing parameter.(-e|-s|-w parameters are optional) Usage: send -p <policy_version> -c <command_execution_id> -m|-f <message_content>|<file_path> -e|-s|-w') print(
'Wrong or missing parameter.(-e|-s|-w parameters are optional) Usage: send -p <policy_version> -c <command_execution_id> -m|-f <message_content>|<file_path> -e|-s|-w')
return None return None
else: else:
print('Wrong or missing parameter. Usage: send -p <policy_version> -c <command_execution_id> -m|-f <message_content>|<file_path> -e|-s|-w') print(
'Wrong or missing parameter. Usage: send -p <policy_version> -c <command_execution_id> -m|-f <message_content>|<file_path> -e|-s|-w')
return None return None
resp = str(response).replace("\"{", "{") resp = str(response).replace("\"{", "{")