Skip to content

Commit 6481a86

Browse files
committed
rminor release for enum34 bug fix
1 parent feff9da commit 6481a86

29 files changed

+1806
-2976
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing Guidelines
22

3-
For anyone looking to get involved in this project, we are glad to hear from you. Here are a few types of contributions
3+
For anyone looking to get involved to this project, we are glad to hear from you. Here are a few types of contributions
44
that we would be interested in hearing about.
55

66
* Bug fixes
@@ -12,12 +12,14 @@ that we would be interested in hearing about.
1212
- If you'd like to accomplish something in the library that it doesn't already do, describe the problem in a new
1313
Github Issue.
1414
- Issues that have been identified as a feature request will be labelled `enhancement`.
15-
- If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending too much time writing the code. In some cases, `enhancement`s may not align well with the project objectives at the time.
15+
- If you'd like to implement the new feature, please wait for feedback from the project maintainers before spending
16+
too much time writing the code. In some cases, `enhancement`s may not align well with the project objectives at
17+
the time.
1618
* Tests, Documentation, Miscellaneous
1719
- If you think the test coverage could be improved, the documentation could be clearer, you've got an alternative
18-
implementation of something that may have more advantages or any other change we would still be glad to hear about
20+
implementation of something that may have more advantages, or any other change we would still be glad hear about
1921
it.
20-
- If it's a trivial change, go ahead and send a Pull Request with the changes you have in mind
22+
- If its a trivial change, go ahead and send a Pull Request with the changes you have in mind
2123
- If not, open a Github Issue to discuss the idea first.
2224

2325
## Requirements
@@ -35,7 +37,7 @@ continue to add more commits to the branch you have sent the Pull Request from.
3537

3638
1. Fork this repository on GitHub.
3739
1. Clone/fetch your fork to your local development machine.
38-
1. Create a new branch (e.g. `issue-12`, `feat.add_foo`, etc.) and check it out.
40+
1. Create a new branch (e.g. `issue-12`, `feat.add_foo`, etc) and check it out.
3941
1. Make your changes and commit them. (Did the tests pass?)
4042
1. Push your new branch to your fork. (e.g. `git push myname issue-12`)
4143
1. Open a Pull Request from your new branch to the original fork's `master` branch.

opentok/archives.py

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,22 @@
33
import json
44
import pytz
55
from enum import Enum
6-
76
if PY3:
87
from datetime import timezone
98

109
# compat
1110
from six.moves import map
1211

13-
dthandler = (
14-
lambda obj: obj.isoformat()
15-
if isinstance(obj, datetime) or isinstance(obj, date)
16-
else None
17-
)
18-
12+
dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime) or isinstance(obj, date) else None
1913

2014
class OutputModes(Enum):
2115
"""List of valid settings for the output_mode parameter of the OpenTok.start_archive()
2216
method."""
23-
24-
composed = u("composed")
17+
composed = u('composed')
2518
"""All streams in the archive are recorded to a single (composed) file."""
26-
individual = u("individual")
19+
individual = u('individual')
2720
"""Each stream in the archive is recorded to an individual file."""
2821

29-
3022
class Archive(object):
3123
"""Represents an archive of an OpenTok session.
3224
@@ -95,26 +87,22 @@ class Archive(object):
9587

9688
def __init__(self, sdk, values):
9789
self.sdk = sdk
98-
self.id = values.get("id")
99-
self.name = values.get("name")
100-
self.status = values.get("status")
101-
self.session_id = values.get("sessionId")
102-
self.partner_id = values.get("partnerId")
90+
self.id = values.get('id')
91+
self.name = values.get('name')
92+
self.status = values.get('status')
93+
self.session_id = values.get('sessionId')
94+
self.partner_id = values.get('partnerId')
10395
if PY2:
104-
self.created_at = datetime.fromtimestamp(
105-
values.get("createdAt") / 1000, pytz.UTC
106-
)
96+
self.created_at = datetime.fromtimestamp(values.get('createdAt') / 1000, pytz.UTC)
10797
if PY3:
108-
self.created_at = datetime.fromtimestamp(
109-
values.get("createdAt") // 1000, timezone.utc
110-
)
111-
self.size = values.get("size")
112-
self.duration = values.get("duration")
113-
self.has_audio = values.get("hasAudio")
114-
self.has_video = values.get("hasVideo")
115-
self.output_mode = OutputModes[values.get("outputMode", "composed")]
116-
self.url = values.get("url")
117-
self.resolution = values.get("resolution")
98+
self.created_at = datetime.fromtimestamp(values.get('createdAt') // 1000, timezone.utc)
99+
self.size = values.get('size')
100+
self.duration = values.get('duration')
101+
self.has_audio = values.get('hasAudio')
102+
self.has_video = values.get('hasVideo')
103+
self.output_mode = OutputModes[values.get('outputMode', 'composed')]
104+
self.url = values.get('url')
105+
self.resolution = values.get('resolution')
118106

119107
def stop(self):
120108
"""
@@ -124,7 +112,7 @@ def stop(self):
124112
disconnected from the session being archived.
125113
"""
126114
temp_archive = self.sdk.stop_archive(self.id)
127-
for k, v in iteritems(temp_archive.attrs()):
115+
for k,v in iteritems(temp_archive.attrs()):
128116
setattr(self, k, v)
129117

130118
def delete(self):
@@ -142,26 +130,29 @@ def attrs(self):
142130
"""
143131
Returns a dictionary of the archive's attributes.
144132
"""
145-
return dict((k, v) for k, v in iteritems(self.__dict__) if k != "sdk")
133+
return dict((k, v) for k, v in iteritems(self.__dict__) if k is not "sdk")
146134

147135
def json(self):
148136
"""
149137
Returns a JSON representation of the archive.
150138
"""
151139
return json.dumps(self.attrs(), default=dthandler, indent=4)
152140

153-
154141
class ArchiveList(object):
142+
155143
def __init__(self, sdk, values):
156-
self.count = values.get("count")
157-
self.items = list(map(lambda x: Archive(sdk, x), values.get("items", [])))
144+
self.count = values.get('count')
145+
self.items = list(map(lambda x: Archive(sdk, x), values.get('items', [])))
158146

159147
def __iter__(self):
160148
for x in self.items:
161149
yield x
162150

163151
def attrs(self):
164-
return {"count": self.count, "items": map(Archive.attrs, self.items)}
152+
return {
153+
'count': self.count,
154+
'items': map(Archive.attrs, self.items)
155+
}
165156

166157
def json(self):
167158
return json.dumps(self.attrs(), default=dthandler, indent=4)
@@ -170,9 +161,7 @@ def __getitem__(self, key):
170161
return self.items.get(key)
171162

172163
def __setitem__(self, key, item):
173-
raise ArchiveError(
174-
u("Cannot set item {0} for key {1} in Archive object").format(item, key)
175-
)
164+
raise ArchiveError(u('Cannot set item {0} for key {1} in Archive object').format(item, key))
176165

177166
def __len__(self):
178167
return len(self.items)

opentok/broadcast.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import json
22

3-
43
class Broadcast(object):
54
"""
65
Represents a live streaming broadcast
76
"""
87

98
def __init__(self, kwargs):
10-
self.id = kwargs.get("id")
11-
self.sessionId = kwargs.get("sessionId")
12-
self.projectId = kwargs.get("projectId")
13-
self.createdAt = kwargs.get("createdAt")
14-
self.updatedAt = kwargs.get("updatedAt")
15-
self.resolution = kwargs.get("resolution")
16-
self.status = kwargs.get("status")
17-
self.broadcastUrls = kwargs.get("broadcastUrls")
9+
self.id = kwargs.get('id')
10+
self.sessionId = kwargs.get('sessionId')
11+
self.projectId = kwargs.get('projectId')
12+
self.createdAt = kwargs.get('createdAt')
13+
self.updatedAt = kwargs.get('updatedAt')
14+
self.resolution = kwargs.get('resolution')
15+
self.status = kwargs.get('status')
16+
self.broadcastUrls = kwargs.get('broadcastUrls')
1817

1918
def json(self):
2019
"""

opentok/endpoints.py

Lines changed: 21 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,69 @@
1-
import warnings
2-
3-
41
class Endpoints(object):
52
"""
63
For internal use.
74
Class that provides the endpoint urls
85
"""
9-
106
def __init__(self, api_url, api_key):
117
self.api_url = api_url
128
self.api_key = api_key
139

14-
def get_session_url(self):
15-
url = self.api_url + "/session/create"
16-
return url
17-
1810
def session_url(self):
19-
warnings.warn(
20-
"endpoints.session_url is deprecated (use endpoints.get_session_url instead).",
21-
DeprecationWarning,
22-
stacklevel=2,
23-
)
24-
25-
return self.get_session_url()
26-
27-
def get_archive_url(self, archive_id=None):
28-
url = self.api_url + "/v2/project/" + self.api_key + "/archive"
29-
if archive_id:
30-
url = url + "/" + archive_id
11+
url = self.api_url + '/session/create'
3112
return url
3213

3314
def archive_url(self, archive_id=None):
34-
warnings.warn(
35-
"endpoints.archive_url is deprecated (use endpoints.get_archive_url instead).",
36-
DeprecationWarning,
37-
stacklevel=2,
38-
)
39-
return self.get_archive_url(archive_id)
15+
url = self.api_url + '/v2/project/' + self.api_key + '/archive'
16+
if archive_id:
17+
url = url + '/' + archive_id
18+
return url
4019

41-
def get_signaling_url(self, session_id, connection_id=None):
42-
url = self.api_url + "/v2/project/" + self.api_key + "/session/" + session_id
20+
def signaling_url(self, session_id, connection_id=None):
21+
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id
4322

4423
if connection_id:
45-
url += "/connection/" + connection_id
24+
url += '/connection/' + connection_id
4625

47-
url += "/signal"
26+
url += '/signal'
4827
return url
4928

50-
def signaling_url(self, session_id, connection_id=None):
51-
warnings.warn(
52-
"endpoints.signaling_url is deprecated (use endpoints.get_signaling_url instead).",
53-
DeprecationWarning,
54-
stacklevel=2,
55-
)
56-
return self.get_signaling_url(session_id, connection_id)
57-
5829
def get_stream_url(self, session_id, stream_id=None):
5930
""" this method returns the url to get streams information """
60-
url = (
61-
self.api_url
62-
+ "/v2/project/"
63-
+ self.api_key
64-
+ "/session/"
65-
+ session_id
66-
+ "/stream"
67-
)
31+
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
6832
if stream_id:
69-
url = url + "/" + stream_id
33+
url = url + '/' + stream_id
7034
return url
7135

72-
def broadcast_url(self, broadcast_id=None, stop=False, layout=False):
73-
warnings.warn(
74-
"endpoints.broadcast_url is deprecated (use endpoints.get_broadcast_url instead).",
75-
DeprecationWarning,
76-
stacklevel=2,
77-
)
78-
return self.get_broadcast_url(broadcast_id, stop, layout)
79-
8036
def force_disconnect_url(self, session_id, connection_id):
8137
""" this method returns the force disconnect url endpoint """
8238
url = (
83-
self.api_url
84-
+ "/v2/project/"
85-
+ self.api_key
86-
+ "/session/"
87-
+ session_id
88-
+ "/connection/"
89-
+ connection_id
39+
self.api_url + '/v2/project/' + self.api_key + '/session/' +
40+
session_id + '/connection/' + connection_id
9041
)
9142
return url
9243

9344
def set_archive_layout_url(self, archive_id):
9445
""" this method returns the url to set the archive layout """
95-
url = (
96-
self.api_url
97-
+ "/v2/project/"
98-
+ self.api_key
99-
+ "/archive/"
100-
+ archive_id
101-
+ "/layout"
102-
)
46+
url = self.api_url + '/v2/project/' + self.api_key + '/archive/' + archive_id + '/layout'
10347
return url
10448

10549
def dial_url(self):
10650
""" this method returns the url to initialize a SIP call """
107-
url = self.api_url + "/v2/project/" + self.api_key + "/dial"
51+
url = self.api_url + '/v2/project/' + self.api_key + '/dial'
10852
return url
10953

11054
def set_stream_class_lists_url(self, session_id):
11155
""" this method returns the url to set the stream class list """
112-
url = (
113-
self.api_url
114-
+ "/v2/project/"
115-
+ self.api_key
116-
+ "/session/"
117-
+ session_id
118-
+ "/stream"
119-
)
56+
url = self.api_url + '/v2/project/' + self.api_key + '/session/' + session_id + '/stream'
12057
return url
12158

122-
def get_broadcast_url(self, broadcast_id=None, stop=False, layout=False):
59+
def broadcast_url(self, broadcast_id=None, stop=False, layout=False):
12360
""" this method returns urls for working with broadcast """
124-
url = self.api_url + "/v2/project/" + self.api_key + "/broadcast"
61+
url = self.api_url + '/v2/project/' + self.api_key + '/broadcast'
12562

12663
if broadcast_id:
127-
url = url + "/" + broadcast_id
64+
url = url + '/' + broadcast_id
12865
if stop:
129-
url = url + "/stop"
66+
url = url + '/stop'
13067
if layout:
131-
url = url + "/layout"
68+
url = url + '/layout'
13269
return url

0 commit comments

Comments
 (0)