self._respond("Unknown command in request. Cannot handle reply. Reply is: %s" % line, success=False)
except Exception, e:
self._respond(str(e), success=False)
def _PE_maxsessiontime(self, line):
lines = line.splitlines()
try:
limit = lines[0].strip().capitalize()
except IndexError:
raise ValueError("Empty reply from rating engine")
try:
limit = int(limit)
except:
if limit == 'None':
limit = None
elif limit == 'Locked':
pass
else:
- raise ValueError("limit must be a non-negative number, None or Locked: %s" % limit)
+ raise ValueError("rating engine limit must be a positive number, None or Locked: got '%s' from %s:%s" % (limit, self.transport.getPeer().host, self.transport.getPeer().port))
else:
if limit < 0:
- raise ValueError("limit must be a non-negative number, None or Locked: %s" % limit)
+ raise ValueError("rating engine limit must be a positive number, None or Locked: got '%s' from %s:%s" % (limit, self.transport.getPeer().host, self.transport.getPeer().port))
info = dict(line.split('=', 1) for line in lines[1:])
if 'type' in info:
type = info['type'].lower()
if type == 'prepaid':
prepaid = True
elif type == 'postpaid':
prepaid = False
else:
- raise ValueError("prepaid must be either True or False: %s" % type)
+ raise ValueError("prepaid must be either True or False: got '%s' from %s:%s" % (type, self.transport.getPeer().host, self.transport.getPeer().port))
else:
prepaid = limit is not None
return limit, prepaid
def _PE_debitbalance(self, line):
valid_answers = ('Ok', 'Failed', 'Not prepaid')
lines = line.splitlines()
try:
result = lines[0].strip().capitalize()
except IndexError:
- raise ValueError("Empty reply from rating engine")
+ raise ValueError("Empty reply from rating engine %s:%s", (self.transport.getPeer().host, self.transport.getPeer().port))
if result not in valid_answers:
- log.error("Invalid reply from rating engine: `%s'" % lines[0].strip())
+ log.error("Invalid reply from rating engine: got '%s' from %s:%s" % (lines[0].strip(), self.transport.getPeer().host, self.transport.getPeer().port))
log.warning('Rating engine possible failed query: %s', self.__request)