diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2019-11-20 12:37:41 +0100 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2020-01-13 14:11:48 +0100 |
commit | 52ef60fe96a99a8d85fb71514ea829236079b34e (patch) | |
tree | a5b3aa5165533733bfb378a1ea436718b1fa80aa /contrib/dgsm/osmo-mslookup-pipe.py | |
parent | 3a9f2679837e793e5520685f3b65730208098ecd (diff) |
add osmo-mslookup-client program (#2)
Standalone program using libosmo-mslookup to easily integrate with programs
that want to connect services (SIP, SMS,...) to the current location of a
subscriber. Also useful for manual testing.
For a detailed overview of the D-GSM and mslookup related files, please see the
elaborate comment at the top of mslookup.c (already added in an earlier patch).
Resubmit of 637bbfcd9275f8c47212b29b50110f56ba6397bf after revert in
41fe3625915c456513544b99ba8c057c0f650b3c.
Change-Id: Ie39d30e20461ab10ae3584863d8bfc6b76a12f37
Diffstat (limited to 'contrib/dgsm/osmo-mslookup-pipe.py')
-rwxr-xr-x | contrib/dgsm/osmo-mslookup-pipe.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/contrib/dgsm/osmo-mslookup-pipe.py b/contrib/dgsm/osmo-mslookup-pipe.py new file mode 100755 index 0000000..b18bf5f --- /dev/null +++ b/contrib/dgsm/osmo-mslookup-pipe.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# vim: shiftwidth=4 tabstop=4 expandtab +import subprocess +import json + +def query_mslookup(query_str): + result = {'result': 'not-found'} + proc = subprocess.Popen(('osmo-mslookup-client', '-f', 'json', query_str), + stdout=subprocess.PIPE) + for line in iter(proc.stdout.readline,''): + if not line: + break + response = json.loads(line) + if response.get('result') == 'result': + result = response + print('Response: %r' % response) + return result + +if __name__ == '__main__': + import sys + query_str = '1000-5000@sip.voice.12345.msisdn' + if len(sys.argv) > 1: + query_str = sys.argv[1] + print('Final result: %r' % query_mslookup(query_str)) |