@@ -367,11 +367,23 @@ def create_session(
367
367
# build options
368
368
options = {}
369
369
if not isinstance (media_mode , MediaModes ):
370
- raise OpenTokException (u ("Cannot create session, {0} is not a valid media mode" ).format (media_mode ))
370
+ raise OpenTokException (
371
+ u ("Cannot create session, {0} is not a valid media mode" ).format (
372
+ media_mode
373
+ )
374
+ )
371
375
if not isinstance (archive_mode , ArchiveModes ):
372
- raise OpenTokException (u ("Cannot create session, {0} is not a valid archive mode" ).format (archive_mode ))
376
+ raise OpenTokException (
377
+ u ("Cannot create session, {0} is not a valid archive mode" ).format (
378
+ archive_mode
379
+ )
380
+ )
373
381
if archive_mode == ArchiveModes .always and media_mode != MediaModes .routed :
374
- raise OpenTokException (u ("A session with always archive mode must also have the routed media mode." ))
382
+ raise OpenTokException (
383
+ u (
384
+ "A session with always archive mode must also have the routed media mode."
385
+ )
386
+ )
375
387
options [u ("p2p.preference" )] = media_mode .value
376
388
options [u ("archiveMode" )] = archive_mode .value
377
389
if location :
@@ -380,9 +392,9 @@ def create_session(
380
392
inet_aton (location )
381
393
except :
382
394
raise OpenTokException (
383
- u ("Cannot create session. Location must be either None or a valid IPv4 address {0}" ). format (
384
- location
385
- )
395
+ u (
396
+ "Cannot create session. Location must be either None or a valid IPv4 address {0}"
397
+ ). format ( location )
386
398
)
387
399
options [u ("location" )] = location
388
400
options ["e2ee" ] = e2ee
@@ -402,7 +414,6 @@ def create_session(
402
414
proxies = self .proxies ,
403
415
timeout = self .timeout ,
404
416
)
405
-
406
417
response .encoding = "utf-8"
407
418
408
419
if response .status_code == 403 :
@@ -437,31 +448,6 @@ def create_session(
437
448
except Exception as e :
438
449
raise OpenTokException ("Failed to generate session: %s" % str (e ))
439
450
440
- try :
441
- error = dom .getElementsByTagName ("error" )
442
- if error :
443
- error = error [0 ]
444
- raise AuthError (
445
- "Failed to create session (code=%s): %s"
446
- % (
447
- error .attributes ["code" ].value ,
448
- error .firstChild .attributes ["message" ].value ,
449
- )
450
- )
451
-
452
- session_id = (
453
- dom .getElementsByTagName ("session_id" )[0 ].childNodes [0 ].nodeValue
454
- )
455
- return Session (
456
- self ,
457
- session_id ,
458
- location = location ,
459
- media_mode = media_mode ,
460
- archive_mode = archive_mode ,
461
- )
462
- except Exception as e :
463
- raise OpenTokException ("Failed to generate session: %s" % str (e ))
464
-
465
451
def get_headers (self ):
466
452
"""For internal use."""
467
453
return {
0 commit comments