Change in python/osmo-python-tests[master]: Drop unused Trap() class

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
Wed Nov 28 12:52:48 UTC 2018


Max has submitted this change and it was merged. ( https://gerrit.osmocom.org/11973 )

Change subject: Drop unused Trap() class
......................................................................

Drop unused Trap() class

Change-Id: Ic2066a66f99a059fc65cf3092170e248288c04d4
---
M osmopy/trap_helper.py
1 file changed, 0 insertions(+), 59 deletions(-)

Approvals:
  Pau Espin Pedrol: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/osmopy/trap_helper.py b/osmopy/trap_helper.py
index f7a64c8..6f4b95d 100644
--- a/osmopy/trap_helper.py
+++ b/osmopy/trap_helper.py
@@ -71,65 +71,6 @@
     loc = split_type(v)
     return partial(lambda a, i: a[i] if len(a) > i else None, loc)
 
-class Trap(CTRL):
-    """
-    TRAP handler (agnostic to factory's client object)
-    """
-    def ctrl_TRAP(self, data, op_id, v):
-        """
-        Parse CTRL TRAP and dispatch to appropriate handler after normalization
-        """
-        self.factory.log.debug('TRAP %s' % v)
-        (l, r) = v.split()
-        loc = l.split('.')
-        t_type = loc[-1]
-        p = partial(lambda a, i: a[i] if len(a) > i else None, loc) # parse helper
-        method = getattr(self, 'handle_' + t_type.replace('-', ''), lambda *_: "Unhandled %s trap" % t_type)
-        method(p(1), p(3), p(5), p(7), r) # we expect net.0.bsc.666.bts.2.trx.1 format for trap prefix
-
-    def ctrl_SET_REPLY(self, data, _, v):
-        """
-        Debug log for replies to our commands
-        """
-        self.factory.log.debug('SET REPLY %s' % v)
-
-    def ctrl_ERROR(self, data, op_id, v):
-        """
-        We want to know if smth went wrong
-        """
-        self.factory.log.debug('CTRL ERROR [%s] %s' % (op_id, v))
-
-    def connectionMade(self):
-        """
-        Logging wrapper, calling super() is necessary not to break reconnection logic
-        """
-        self.factory.log.info("Connected to CTRL@%s:%d" % (self.factory.host, self.factory.port))
-        super(CTRL, self).connectionMade()
-
-    @defer.inlineCallbacks
-    def handle_locationstate(self, net, bsc, bts, trx, data):
-        """
-        Handle location-state TRAP: parse trap content, prepare parameters and use treq's routines to post it while setting up async handlers
-        """
-        (ts, fx, lat, lon, height, opr, adm, pol, mcc, mnc) = data.split(',')
-        tstamp = datetime.datetime.fromtimestamp(float(ts)).isoformat()
-        self.factory.log.debug('location-state@%s.%s.%s.%s (%s) [%s/%s] => %s' % (net, bsc, bts, trx, tstamp, mcc, mnc, data))
-
-        d = self.factory.prepare_params(bsc, lon, lat, fix.get(fx, 0), tstamp, oper.get(opr, 2), admin.get(adm, 2), policy.get(pol, 3))
-
-        d.addErrback(lambda e, bsc: self.factory.log.critical("HTTP POST error %s while trying to register BSC %s on %s" % (e, bsc, self.factory.location)), bsc) # handle HTTP errors
-        # Ensure that we run only limited number of requests in parallel:
-        yield self.factory.semaphore.acquire()
-        yield d # we end up here only if semaphore is available which means it's ok to fire the request without exceeding the limit
-        self.factory.semaphore.release()
-
-    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))
-
-
 def reloader(path, script, log, dbg1, dbg2, signum, _):
     """
     Signal handler: we have to use execl() because twisted's reactor is not restartable due to some bug in twisted implementation

-- 
To view, visit https://gerrit.osmocom.org/11973
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: merged
Gerrit-Change-Id: Ic2066a66f99a059fc65cf3092170e248288c04d4
Gerrit-Change-Number: 11973
Gerrit-PatchSet: 2
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181128/442806d6/attachment.htm>


More information about the gerrit-log mailing list