Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coalesced changes from variosus sources.. #4

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The project has been uploaded to pypi, and you can view the library from [here](
pip install bigbluebutton_api_python
```

You can also install the latest from this repo with
```shell
pip install git+git://github.com/101t/bigbluebutton-api-python.git
```


## Example
Example to use the library:
```python
Expand All @@ -20,7 +26,7 @@ print(b.get_api_version().get_version())
```
## Others Example

```
```python
from bigbluebutton_api_python import BigBlueButton

b = BigBlueButton('your BBB server url', 'your server credential')
Expand Down
15 changes: 9 additions & 6 deletions bigbluebutton_api_python/bigbluebutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
from jxmlease import parse
from hashlib import sha1
if sys.version_info[0] == 2:
from urllib import urlencode, urlopen
from urllib import quote
from urllib2 import urlopen ,Request
from urllib import quote,urlencode
else:
from urllib.request import urlopen
from urllib.request import Request, urlopen
from urllib.parse import urlencode
from urllib.request import quote


class BigBlueButton:

def __init__(self, bbbServerBaseUrl, securitySalt):
Expand Down Expand Up @@ -132,9 +131,13 @@ def __send_api_request(self, api_call, params={}, data=None):

# if data is none, then we send a GET request, if not, then we send a POST request
if data is None:
response = urlopen(url).read()
response = urlopen(url, timeout=10).read()
else:
response = urlopen(url, data=urlencode(data).encode()).read()
if isinstance(data, str):
request = Request(url, data=bytes(data, "utf8"), headers={'Content-Type': 'application/xml'})
response = urlopen(request, timeout=10).read()
else:
response = urlopen(url, timeout=10, data=urlencode(data).encode()).read()

try:
rawXml = parse(response)["response"]
Expand Down
6 changes: 4 additions & 2 deletions bigbluebutton_api_python/parameters/bbbmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self):
def add_slide(self, type, value, name = None):
if type == self.URL:
self.__urls.append(value)
elif type == self.files:
elif type == self.FILE:
self.__files.append(value)
elif type == self.base64s:
self.__base64s.append([name, value])
Expand Down Expand Up @@ -45,5 +45,7 @@ def __slides_to_xml(self):
with open(single_file, 'r') as f:
xml += base64.encodestring(f.read())
xml += "</document>"

xml += "</module>"

return xml
return xml
11 changes: 8 additions & 3 deletions bigbluebutton_api_python/responses/getmeetings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .base import BaseResponse
from ..core.meeting import Meeting
import jxmlease

class GetMeetingsResponse(BaseResponse):
def get_meetings(self):
Expand All @@ -11,6 +12,10 @@ def get_meetings(self):
except KeyError:
pass

for meetingXml in self.get_field("meetings")["meeting"]:
meetings.append(Meeting(meetingXml))
return meetings
meetings_data = self.get_field("meetings")["meeting"]
if isinstance(meetings_data, jxmlease.dictnode.XMLDictNode):
meetings.append(Meeting(meetings_data))
else:
for meetingXml in self.get_field("meetings")["meeting"]:
meetings.append(Meeting(meetingXml))
return meetings