Change in python/osmo-python-tests[master]: ctrl2cgi: explicitly ignore unrelated TRAPs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri Dec 21 16:51:21 UTC 2018


Max has uploaded this change for review. ( https://gerrit.osmocom.org/12421


Change subject: ctrl2cgi: explicitly ignore unrelated TRAPs
......................................................................

ctrl2cgi: explicitly ignore unrelated TRAPs

Previously we've tried to determine the type of TRAP and handle as many
as possible via generic method dispatcher similar to parent class. Let's
make code simpler by explicitly ignoring all but 'location-state'
TRAPs. This should also reduce debug log output because we'll only log
the TRAP variable for ignored messages instead of entire content.

Change-Id: I42b715cb82eb309950ff387649726504b6c7cf61
Related: SYS#4399
---
M scripts/ctrl2cgi.py
1 file changed, 5 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/python/osmo-python-tests refs/changes/21/12421/1

diff --git a/scripts/ctrl2cgi.py b/scripts/ctrl2cgi.py
index 3226c1d..0144f37 100755
--- a/scripts/ctrl2cgi.py
+++ b/scripts/ctrl2cgi.py
@@ -84,11 +84,11 @@
         """
         Parse CTRL TRAP and dispatch to appropriate handler after normalization
         """
-        self.factory.log.debug('TRAP %s' % v)
-        t_type = get_type(v)
-        p = p_h(v)
-        method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: "Unhandled %s trap" % t_type)
-        method(p(1), p(3), p(5), p(7), get_r(v))
+        if get_type(v) == 'location-state':
+            p = p_h(v)
+            self.handle_locationstate(p(1), p(3), p(5), p(7), get_r(v))
+        else:
+            self.factory.log.debug('Ignoring TRAP %s' % (v.split()[0]))
 
     def ctrl_SET_REPLY(self, data, _, v):
         """
@@ -121,12 +121,6 @@
         # Ensure that we run only limited number of requests in parallel:
         self.factory.semaphore.run(make_async_req, t, self.factory.location, params, self.transport.write, self.factory.log, self.factory.timeout)
 
-    def handle_notificationrejectionv1(self, net, bsc, bts, trx, data):
-        """
-        Handle notification-rejection-v1 TRAP: just an example to show how more message types can be handled
-        """
-        self.factory.log.debug('notification-rejection-v1 at bsc-id %s => %s' % (bsc, data))
-
 
 class TrapFactory(IPAFactory):
     """

-- 
To view, visit https://gerrit.osmocom.org/12421
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: python/osmo-python-tests
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I42b715cb82eb309950ff387649726504b6c7cf61
Gerrit-Change-Number: 12421
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181221/6ae30ada/attachment.htm>


More information about the gerrit-log mailing list