MT#62763 Fix Python code compilation with Python 3.x

The code had not been converted to Python 3.x, and was not even
compiling there, with something like:

  $ find -name '*.py' | xargs -n1 python3 -m py_compute

Change-Id: I795f931123d1bccb85670fe0dc6b06c46a9f22c2
mr26.0
Guillem Jover 5 months ago
parent b2915b33a5
commit a74c34208c

@ -39,22 +39,22 @@ class IvrDialog(IvrDialogBase):
conf_duration = 0
def sessionInfo(self):
print "IVR Session info:"
print " user: ", self.dialog.user
print " domain: ", self.dialog.domain
print " sip_ip: ", self.dialog.sip_ip
print " sip_port: ", self.dialog.sip_port
print " local_uri: ", self.dialog.local_uri
print " remote_uri: ", self.dialog.remote_uri
print " contact_uri: ", self.dialog.contact_uri
print " callid: ", self.dialog.callid
print " remote_tag: ", self.dialog.remote_tag
print " local_tag: ", self.dialog.local_tag
print " remote_party:", self.dialog.remote_party
print " local_party: ", self.dialog.local_party
print " route: ", self.dialog.route
print " next_hop: ", self.dialog.next_hop
print " cseq: ", self.dialog.cseq
print("IVR Session info:")
print(" user: ", self.dialog.user)
print(" domain: ", self.dialog.domain)
print(" sip_ip: ", self.dialog.sip_ip)
print(" sip_port: ", self.dialog.sip_port)
print(" local_uri: ", self.dialog.local_uri)
print(" remote_uri: ", self.dialog.remote_uri)
print(" contact_uri: ", self.dialog.contact_uri)
print(" callid: ", self.dialog.callid)
print(" remote_tag: ", self.dialog.remote_tag)
print(" local_tag: ", self.dialog.local_tag)
print(" remote_party:", self.dialog.remote_party)
print(" local_party: ", self.dialog.local_party)
print(" route: ", self.dialog.route)
print(" next_hop: ", self.dialog.next_hop)
print(" cseq: ", self.dialog.cseq)
def onSessionStart(self):
self.sessionInfo()
@ -115,7 +115,7 @@ class IvrDialog(IvrDialogBase):
elif self.state == collect:
self.setTimer(HINT_TIMER, HINT_TIMEOUT)
def onTimer(self, id):
def onTimer(self, id):
if id == HINT_TIMER and self.state == collect:
self.enqueue(self.hint_msg, None)
elif id == CONF_TIMER and self.state == connected:

@ -16,14 +16,14 @@ class IvrDialog(IvrDialogBase):
self.enqueue(self.audio_msg,None)
def onEmptyQueue(self):
return
return
def onTimer(self, timerid):
self.disconnectMedia()
debug('hello kitty')
self.connectCallee(self.dialog.local_party,self.dialog.local_uri, \
self.dialog.remote_party,self.dialog.remote_uri,)
return
return
def onBye(self):

@ -30,7 +30,7 @@ class IvrDialog(IvrDialogBase):
def onBye(self):
self.stopSession()
self.stopSession()
def onEmptyQueue(self):

@ -8,10 +8,10 @@ server.register_introspection_functions()
class MyFuncs:
def getCredit(self, arg):
print "Function getCredit"
print " Recieved Pin: ", arg
print("Function getCredit")
print(" Recieved Pin: ", arg)
credit=int(arg)+10
print " Credits: ", credit
print(" Credits: ", credit)
return credit
def subtractCredit(self, arg):
@ -20,12 +20,12 @@ class MyFuncs:
d2 = arg[0]
subtract = d2['amount']
credit=1000-subtract
print "Function subtractCredit "
print " Recieved Arg: ", arg[0]
print " methodName: ", d2['methodName']
print " pin: ", d2['pin']
print " amount: ", d2['amount']
print " credit: ", credit
print("Function subtractCredit ")
print(" Recieved Arg: ", arg[0])
print(" methodName: ", d2['methodName'])
print(" pin: ", d2['pin'])
print(" amount: ", d2['amount'])
print(" credit: ", credit)
return credit
server.register_instance(MyFuncs())

@ -39,9 +39,9 @@ def stacktrace(tb):
line = tb.tb_frame.f_lineno
if f != last_file:
error('File ' + `f` + ': line ' + `line`)
error('File ' + repr(f) + ': line ' + repr(line))
else:
error(', line ' + `line`)
error(', line ' + repr(line))
return f

@ -1,5 +1,5 @@
#!/usr/bin/env python
from xmlrpclib import *
s = ServerProxy('http://127.0.0.1:8092')
print s.setTarget(100, 1, 0, '4', '192.168.5.110', 2, 0, 30, 40)
print(s.setTarget(100, 1, 0, '4', '192.168.5.110', 2, 0, 30, 40))

@ -26,11 +26,11 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if __name__ == '__main__':
server_class = BaseHTTPServer.HTTPServer
httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler)
print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER)
print(time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER))
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()
print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)
print(time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER))

@ -11,10 +11,10 @@ r = set()
while True:
n = randint(400, 499)
if n in r:
print s.removeRegistration(n)
print(s.removeRegistration(n))
r.remove(n)
else:
print s.createRegistration(n, str(n), str(n), '192.168.5.110')
print(s.createRegistration(n, str(n), str(n), '192.168.5.110'))
r.add(n)
time.sleep(.1)

@ -56,7 +56,7 @@ class IvrDialog(IvrDialogBase):
self.welcome_msg = IvrAudioFile()
self.welcome_msg.open(config['welcome_msg'],AUDIO_READ)
self.pin_msg = IvrAudioFile()
self.pin_msg = IvrAudioFile()
self.pin_msg.open(config['pin_msg'],AUDIO_READ)
self.enqueue(self.welcome_msg,None)

@ -20,5 +20,5 @@ server = SimpleXMLRPCServer.SimpleXMLRPCServer(("127.0.0.1", 9090))
server.register_instance(authsrv)
#Go into the main listener loop
print "Listening on port 9090"
print("Listening on port 9090")
server.serve_forever()

@ -39,9 +39,9 @@ def stacktrace(tb):
line = tb.tb_frame.f_lineno
if f != last_file:
error('File ' + `f` + ': line ' + `line`)
error('File ' + repr(f) + ': line ' + repr(line))
else:
error(', line ' + `line`)
error(', line ' + repr(line))
return f

@ -8,10 +8,10 @@ server.register_introspection_functions()
class MyFuncs:
def getCredit(self, arg):
print "Function getCredit"
print " Recieved Pin: ", arg
print("Function getCredit")
print(" Recieved Pin: ", arg)
credit=int(arg)+10
print " Credits: ", credit
print(" Credits: ", credit)
return credit
def subtractCredit(self, arg):
@ -20,12 +20,12 @@ class MyFuncs:
d2 = arg[0]
subtract = d2['amount']
credit=1000-subtract
print "Function subtractCredit "
print " Recieved Arg: ", arg[0]
print " methodName: ", d2['methodName']
print " pin: ", d2['pin']
print " amount: ", d2['amount']
print " credit: ", credit
print("Function subtractCredit ")
print(" Recieved Arg: ", arg[0])
print(" methodName: ", d2['methodName'])
print(" pin: ", d2['pin'])
print(" amount: ", d2['amount'])
print(" credit: ", credit)
return credit
server.register_instance(MyFuncs())

@ -27,7 +27,7 @@ from account import *
#CONTROL_URI="http://127.0.0.1:8090/"
CONTROL_URI="https://webconference.iptel.org/control"
print "Server Control URI: '%s' - change CONTROL_URI to use local SEMS instance" % CONTROL_URI
print("Server Control URI: '%s' - change CONTROL_URI to use local SEMS instance" % CONTROL_URI)
# refresh in ms
REFRESH_INTERVAL=1000
@ -37,7 +37,7 @@ try:
from accountconfig import *
HAS_ACCOUNT=True
except:
print "accountconfig.py not found - will ask for account to make calls"
print("accountconfig.py not found - will ask for account to make calls")
pass
class named_participant(Ui_participant):
@ -71,7 +71,7 @@ class named_participant(Ui_participant):
self.cb_muted.setCheckState(Qt.Unchecked)
def muted_changed(self, i):
print "callid is" , self.callid
print("callid is" , self.callid)
self.cb_muted.emit(QtCore.SIGNAL("mute(int,bool)"), self.id, self.cb_muted.isChecked())
@ -107,20 +107,20 @@ class StartQT4(QtGui.QMainWindow):
QtCore.QObject.connect(self.ui.buttonNew, QtCore.SIGNAL("clicked()"), self.new_call)
self.s = ServerProxy(CONTROL_URI)
print "server has %d running calls " % self.s.calls()
print("server has %d running calls " % self.s.calls())
for i in range(10):
self.roomname = ""
for n in range(6):
self.roomname+=str(random.randint(0,9))
code, result, adminpin, serverstatus = self.s.di('webconference', 'roomCreate', self.roomname)
print "server status: %s " % serverstatus
print("server status: %s " % serverstatus)
if code == 0:
self.adminpin = adminpin
break
if self.adminpin == "":
raise "oh, could not get a free room :("
print "roomname is %s, adminpin is %s "% (self.roomname, self.adminpin)
print("roomname is %s, adminpin is %s "% (self.roomname, self.adminpin))
self.ui.label.setText("iptel.org\nwebconference\nhttps://webconference.iptel.org\n\nroom: %s adminpin:%s\n\n"
"to dial in call sip:conference@iptel.org \nand type %s*"
%(self.roomname, self.adminpin, self.roomname))
@ -132,7 +132,7 @@ class StartQT4(QtGui.QMainWindow):
def timer_hit(self):
res = self.s.di('webconference', 'roomInfo', self.roomname, self.adminpin)
if res[0] != 0:
print "oh my god, can't see this room!"
print("oh my god, can't see this room!")
return
code, reason, participants, serverstatus = res
@ -165,31 +165,31 @@ class StartQT4(QtGui.QMainWindow):
return part
def new_call(self):
print "a new call."
print("a new call.")
dlg = QtGui.QDialog(self)
dlg_cb = Ui_callbox()
dlg_cb.setupUi(dlg)
if dlg.exec_() == QDialog.Rejected:
return
print "now calling %s " % dlg_cb.num.text()
print("now calling %s " % dlg_cb.num.text())
res = self.s.di('webconference', 'dialout', self.roomname, self.adminpin, str(dlg_cb.num.text()),
self.call_user, self.call_domain, self.call_auth_user, self.call_pwd)
if res[0] != 0:
print "oh, my dear, calling failed with code %d " % res[0]
print("oh, my dear, calling failed with code %d " % res[0])
return
code, result, callid, serverinfo = res
print "code %d result %s " % (code, result)
print "serverinfo is %s " % serverinfo
print("code %d result %s " % (code, result))
print("serverinfo is %s " % serverinfo)
self.createparticipantWidget(dlg_cb.num.text(), callid)
def part_ciao(self, id):
print "ciao: ", id
print("ciao: ", id)
self.s.di('webconference', 'kickout', self.roomname, self.adminpin, self.participants[id].callid)
def part_muted(self, id, s):
print "mute: ", id, " is ", s
print("mute: ", id, " is ", s)
if s:
self.s.di('webconference', 'mute', self.roomname, self.adminpin, self.participants[id].callid)
else:

Loading…
Cancel
Save