[PATCH] openbsc[master]: bsc_control.py: convert to python3

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
Mon Dec 5 11:35:07 UTC 2016


Review at  https://gerrit.osmocom.org/1358

bsc_control.py: convert to python3

Let's be consistent with other .py in contrib and use python3
explicitly.

Change-Id: I669be3e8731460d5d9229fd0459ef7dd60e8bd73
---
M openbsc/contrib/bsc_control.py
1 file changed, 7 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/58/1358/1

diff --git a/openbsc/contrib/bsc_control.py b/openbsc/contrib/bsc_control.py
index 125a0c9..28235af 100755
--- a/openbsc/contrib/bsc_control.py
+++ b/openbsc/contrib/bsc_control.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 # -*- mode: python-mode; py-indent-tabs-mode: nil -*-
 
 from optparse import OptionParser
@@ -9,7 +9,7 @@
 
 def connect(host, port):
         if verbose:
-                print "Connecting to host %s:%i" % (host, port)
+                print("Connecting to host %s:%i" % (host, port))
 
         sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
         sck.setblocking(1)
@@ -20,7 +20,7 @@
         (r, c) = Ctrl().cmd(var, value)
         sck.send(c)
         answer = Ctrl().del_header(sck.recv(4096))
-        return (answer,) + Ctrl().verify(answer, r, var, value)
+        return (answer,) + Ctrl().verify(answer.decode('utf-8'), r, var, value)
 
 def set_var(sck, var, val):
         do_set_get(sck, var, val)
@@ -63,20 +63,20 @@
                 if len(args) < 2:
                         parser.error("Set requires var and value arguments")
                 (a, _, _) = do_set_get(sock, args[0], ' '.join(args[1:]))
-                print "Got message:", a
+                print("Got message:", a)
 
         if options.cmd_get:
                 if len(args) != 1:
                         parser.error("Get requires the var argument")
                 (a, _, _) = do_set_get(sock, args[0])
-                print "Got message:", a
+                print("Got message:", a)
 
         if options.monitor:
                 while True:
                         data = sock.recv(1024)
                         if len(data) == 0:
-                                print "Connection is gone."
+                                print("Connection is gone.")
                                 break
-                        print "Got message:", Ctrl().del_header(data)
+                        print("Got message:", Ctrl().del_header(data))
 
         sock.close()

-- 
To view, visit https://gerrit.osmocom.org/1358
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I669be3e8731460d5d9229fd0459ef7dd60e8bd73
Gerrit-PatchSet: 1
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list