From 82d9d524bdb8ce2f54855589e44ce3a20ba1af37 Mon Sep 17 00:00:00 2001
From: cclauss
Date: Mon, 17 Jun 2019 19:21:30 +0200
Subject: Fix seven contrib files with Python syntax errors (#5446)
* Fix seven contrib files with Python syntax errors
Signed-off-by: cclauss
---
contrib/jitsimeetbridge/jitsimeetbridge.py | 67 +++++++++++++++---------------
1 file changed, 34 insertions(+), 33 deletions(-)
(limited to 'contrib/jitsimeetbridge/jitsimeetbridge.py')
diff --git a/contrib/jitsimeetbridge/jitsimeetbridge.py b/contrib/jitsimeetbridge/jitsimeetbridge.py
index 15f8e1c48b..e82d1be5d2 100644
--- a/contrib/jitsimeetbridge/jitsimeetbridge.py
+++ b/contrib/jitsimeetbridge/jitsimeetbridge.py
@@ -8,8 +8,9 @@ we set the remote SDP at which point the stream ends. Our video never gets to
the bridge.
Requires:
-npm install jquery jsdom
+npm install jquery jsdom
"""
+from __future__ import print_function
import gevent
import grequests
@@ -51,7 +52,7 @@ class TrivialMatrixClient:
req = grequests.get(url)
resps = grequests.map([req])
obj = json.loads(resps[0].content)
- print "incoming from matrix",obj
+ print("incoming from matrix",obj)
if 'end' not in obj:
continue
self.token = obj['end']
@@ -60,22 +61,22 @@ class TrivialMatrixClient:
def joinRoom(self, roomId):
url = MATRIXBASE+'rooms/'+roomId+'/join?access_token='+self.access_token
- print url
+ print(url)
headers={ 'Content-Type': 'application/json' }
req = grequests.post(url, headers=headers, data='{}')
resps = grequests.map([req])
obj = json.loads(resps[0].content)
- print "response: ",obj
+ print("response: ",obj)
def sendEvent(self, roomId, evType, event):
url = MATRIXBASE+'rooms/'+roomId+'/send/'+evType+'?access_token='+self.access_token
- print url
- print json.dumps(event)
+ print(url)
+ print(json.dumps(event))
headers={ 'Content-Type': 'application/json' }
req = grequests.post(url, headers=headers, data=json.dumps(event))
resps = grequests.map([req])
obj = json.loads(resps[0].content)
- print "response: ",obj
+ print("response: ",obj)
@@ -85,31 +86,31 @@ xmppClients = {}
def matrixLoop():
while True:
ev = matrixCli.getEvent()
- print ev
+ print(ev)
if ev['type'] == 'm.room.member':
- print 'membership event'
+ print('membership event')
if ev['membership'] == 'invite' and ev['state_key'] == MYUSERNAME:
roomId = ev['room_id']
- print "joining room %s" % (roomId)
+ print("joining room %s" % (roomId))
matrixCli.joinRoom(roomId)
elif ev['type'] == 'm.room.message':
if ev['room_id'] in xmppClients:
- print "already have a bridge for that user, ignoring"
+ print("already have a bridge for that user, ignoring")
continue
- print "got message, connecting"
+ print("got message, connecting")
xmppClients[ev['room_id']] = TrivialXmppClient(ev['room_id'], ev['user_id'])
gevent.spawn(xmppClients[ev['room_id']].xmppLoop)
elif ev['type'] == 'm.call.invite':
- print "Incoming call"
+ print("Incoming call")
#sdp = ev['content']['offer']['sdp']
#print "sdp: %s" % (sdp)
#xmppClients[ev['room_id']] = TrivialXmppClient(ev['room_id'], ev['user_id'])
#gevent.spawn(xmppClients[ev['room_id']].xmppLoop)
elif ev['type'] == 'm.call.answer':
- print "Call answered"
+ print("Call answered")
sdp = ev['content']['answer']['sdp']
if ev['room_id'] not in xmppClients:
- print "We didn't have a call for that room"
+ print("We didn't have a call for that room")
continue
# should probably check call ID too
xmppCli = xmppClients[ev['room_id']]
@@ -146,7 +147,7 @@ class TrivialXmppClient:
return obj
def sendAnswer(self, answer):
- print "sdp from matrix client",answer
+ print("sdp from matrix client",answer)
p = subprocess.Popen(['node', 'unjingle/unjingle.js', '--sdp'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
jingle, out_err = p.communicate(answer)
jingle = jingle % {
@@ -156,28 +157,28 @@ class TrivialXmppClient:
'responder': self.jid,
'sid': self.callsid
}
- print "answer jingle from sdp",jingle
+ print("answer jingle from sdp",jingle)
res = self.sendIq(jingle)
- print "reply from answer: ",res
+ print("reply from answer: ",res)
self.ssrcs = {}
jingleSoup = BeautifulSoup(jingle)
for cont in jingleSoup.iq.jingle.findAll('content'):
if cont.description:
self.ssrcs[cont['name']] = cont.description['ssrc']
- print "my ssrcs:",self.ssrcs
+ print("my ssrcs:",self.ssrcs)
gevent.joinall([
gevent.spawn(self.advertiseSsrcs)
])
def advertiseSsrcs(self):
- time.sleep(7)
- print "SSRC spammer started"
+ time.sleep(7)
+ print("SSRC spammer started")
while self.running:
ssrcMsg = "%(nick)s" % { 'tojid': "%s@%s/%s" % (ROOMNAME, ROOMDOMAIN, self.shortJid), 'nick': self.userId, 'assrc': self.ssrcs['audio'], 'vssrc': self.ssrcs['video'] }
res = self.sendIq(ssrcMsg)
- print "reply from ssrc announce: ",res
+ print("reply from ssrc announce: ",res)
time.sleep(10)
@@ -186,19 +187,19 @@ class TrivialXmppClient:
self.matrixCallId = time.time()
res = self.xmppPoke("" % (self.nextRid(), HOST))
- print res
+ print(res)
self.sid = res.body['sid']
- print "sid %s" % (self.sid)
+ print("sid %s" % (self.sid))
res = self.sendIq("")
res = self.xmppPoke("" % (self.nextRid(), self.sid, HOST))
res = self.sendIq("")
- print res
+ print(res)
self.jid = res.body.iq.bind.jid.string
- print "jid: %s" % (self.jid)
+ print("jid: %s" % (self.jid))
self.shortJid = self.jid.split('-')[0]
res = self.sendIq("")
@@ -217,13 +218,13 @@ class TrivialXmppClient:
if p.c and p.c.nick:
u['nick'] = p.c.nick.string
self.muc['users'].append(u)
- print "muc: ",self.muc
+ print("muc: ",self.muc)
# wait for stuff
while True:
- print "waiting..."
+ print("waiting...")
res = self.sendIq("")
- print "got from stream: ",res
+ print("got from stream: ",res)
if res.body.iq:
jingles = res.body.iq.findAll('jingle')
if len(jingles):
@@ -232,15 +233,15 @@ class TrivialXmppClient:
elif 'type' in res.body and res.body['type'] == 'terminate':
self.running = False
del xmppClients[self.matrixRoom]
- return
+ return
def handleInvite(self, jingle):
self.initiator = jingle['initiator']
self.callsid = jingle['sid']
p = subprocess.Popen(['node', 'unjingle/unjingle.js', '--jingle'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- print "raw jingle invite",str(jingle)
+ print("raw jingle invite",str(jingle))
sdp, out_err = p.communicate(str(jingle))
- print "transformed remote offer sdp",sdp
+ print("transformed remote offer sdp",sdp)
inviteEvent = {
'offer': {
'type': 'offer',
@@ -252,7 +253,7 @@ class TrivialXmppClient:
}
matrixCli.sendEvent(self.matrixRoom, 'm.call.invite', inviteEvent)
-matrixCli = TrivialMatrixClient(ACCESS_TOKEN)
+matrixCli = TrivialMatrixClient(ACCESS_TOKEN) # Undefined name
gevent.joinall([
gevent.spawn(matrixLoop)
--
cgit 1.4.1