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

Update groups #14

Merged
merged 18 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add handling for possibility that zones is passed as a string with an…
… enclosed array ie. 'zones' : '[1,2,3]'
  • Loading branch information
linknum23 committed Nov 3, 2020
commit 2c4848c2fcd23047ca95f2857900a1b4fd9ca066
11 changes: 11 additions & 0 deletions python/ethaudio/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,11 @@ def set_group(self, id, name=None, source_id=None, zones=None, mute=None, vol_de
_, g = self.get_group(id)
if g is None:
return error('set group failed, group {} not found'.format(id))
if type(zones) is str:
try:
zones = eval(zones)
except Exception as e:
return error('failed to configure group, error parsing zones: {}'.format(e))
try:
name, _ = updated_val(name, g['name'])
zones, _ = updated_val(zones, g['zones'])
Expand Down Expand Up @@ -628,6 +633,12 @@ def create_group(self, name, zones):
if name in names:
return error('create group failed: {} already exists'.format(name))

if type(zones) is str:
try:
zones = eval(zones)
except Exception as e:
return error('failed to configure group, error parsing zones: {}'.format(e))

# get the new groug's id
id = self.new_group_id()

Expand Down
1 change: 1 addition & 0 deletions python/ethaudio/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def do_POST(self):
content = self.rfile.read(content_length)

# attempt to parse
print('parsing: {}'.format(content))
parse_error = self.eth_audio_server.parse_command(content)
# reply with appropriate HTTP code
if(parse_error == None):
Expand Down