mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 16:42:20 +03:00
variable name and log format fixing
This commit is contained in:
parent
7a5219c50b
commit
5e91ed708f
1 changed files with 15 additions and 14 deletions
|
@ -9,28 +9,29 @@ from base.system.system import System
|
||||||
|
|
||||||
class Agreement:
|
class Agreement:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
scope = Scope().getInstance()
|
scope = Scope().get_instance()
|
||||||
self.logger = scope.getLogger()
|
self.logger = scope.get_logger()
|
||||||
self.message_manager = scope.getMessageManager()
|
self.message_manager = scope.get_message_manager()
|
||||||
self.messenger = scope.getMessenger()
|
self.messenger = scope.get_messenger()
|
||||||
self.db_service = scope.getDbService()
|
self.db_service = scope.get_db_service()
|
||||||
self.ask_path = '/opt/ahenk/base/agreement/ask.py'
|
self.ask_path = '/opt/ahenk/base/agreement/ask.py'
|
||||||
self.logger.debug('[Agreement] Instance initialized.')
|
self.logger.debug('Instance initialized.')
|
||||||
|
|
||||||
def agreement_contract_update(self):
|
def agreement_contract_update(self):
|
||||||
self.messenger.send_direct_message(self.message_manager.agreement_request_msg())
|
self.messenger.send_direct_message(self.message_manager.agreement_request_msg())
|
||||||
self.logger.debug('[Agreement] Requested updated agreement contract from lider.')
|
self.logger.debug('Requested updated agreement contract from lider.')
|
||||||
|
|
||||||
def check_agreement(self, username):
|
def check_agreement(self, username):
|
||||||
self.logger.debug('[Agreement] Checking agreement for user {0}.'.format(username))
|
self.logger.debug('Checking agreement for user {0}.'.format(username))
|
||||||
contract_id = self.get_current_contract_id()
|
contract_id = self.get_current_contract_id()
|
||||||
if contract_id is None:
|
if contract_id is None:
|
||||||
self.logger.debug('[Agreement] There is no any contract in database.')
|
self.logger.debug('There is no any contract in database.')
|
||||||
contract_id = '-1'
|
contract_id = '-1'
|
||||||
|
|
||||||
if self.db_service.select_one_result('agreement', 'id',
|
if self.db_service.select_one_result('agreement', 'id',
|
||||||
" contract_id='{0}' and username='{1}' and choice='Y' "
|
" contract_id='{0}' and username='{1}' and choice='Y' "
|
||||||
.format(contract_id, username)) is not None:
|
.format(contract_id, username)) is not None:
|
||||||
|
self.logger.debug('{0} answered agreement..')
|
||||||
return True
|
return True
|
||||||
elif self.db_service.select_one_result('agreement', 'id',
|
elif self.db_service.select_one_result('agreement', 'id',
|
||||||
" contract_id='{0}' and username='{1}' and choice='N' ".format(
|
" contract_id='{0}' and username='{1}' and choice='N' ".format(
|
||||||
|
@ -70,23 +71,23 @@ class Agreement:
|
||||||
pout = str(p_out).replace('\n', '')
|
pout = str(p_out).replace('\n', '')
|
||||||
if pout != 'Error':
|
if pout != 'Error':
|
||||||
if pout == 'Y':
|
if pout == 'Y':
|
||||||
self.logger.debug('[Agreement] Agreement was accepted by {0}.'.format(username))
|
self.logger.debug('Agreement was accepted by {0}.'.format(username))
|
||||||
self.db_service.update('agreement', self.db_service.get_cols('agreement'),
|
self.db_service.update('agreement', self.db_service.get_cols('agreement'),
|
||||||
[contract_id, username, Util.timestamp(), 'Y'])
|
[contract_id, username, Util.timestamp(), 'Y'])
|
||||||
elif pout == 'N':
|
elif pout == 'N':
|
||||||
self.db_service.update('agreement', self.db_service.get_cols('agreement'),
|
self.db_service.update('agreement', self.db_service.get_cols('agreement'),
|
||||||
[contract_id, username, Util.timestamp(), 'N'])
|
[contract_id, username, Util.timestamp(), 'N'])
|
||||||
self.logger.debug(
|
self.logger.debug(
|
||||||
'[Agreement] Agreement was ignored by {0}. Session will be closed'.format(username))
|
'Agreement was ignored by {0}. Session will be closed'.format(username))
|
||||||
else:
|
else:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
'[Agreement] A problem occurred while executing ask.py. Error Message: {0}'.format(str(pout)))
|
'A problem occurred while executing ask.py. Error Message: {0}'.format(str(pout)))
|
||||||
Util.delete_file(agreement_path)
|
Util.delete_file(agreement_path)
|
||||||
else:
|
else:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
'[Agreement] A problem occurred while executing ask.py (Probably argument fault). Error Message: {0}'.format(
|
'A problem occurred while executing ask.py (Probably argument fault). Error Message: {0}'.format(
|
||||||
str(pout)))
|
str(pout)))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(
|
self.logger.error(
|
||||||
'[Agreement] A Problem occurred while displaying agreement. Error Message: {0}'.format(str(e)))
|
'A Problem occurred while displaying agreement. Error Message: {0}'.format(str(e)))
|
||||||
|
|
Loading…
Reference in a new issue