Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ifaddr>=0.1.0
jsonschema==2.6.*; python_version < '3.5'
jsonschema==2.6.*; python_version == '2.7'
jsonschema>=3.2.0; python_version >= '3.5'
pyee>=7.0.0
tornado==5.1.*; python_version < '3.5'
tornado==5.1.*; python_version == '2.7'
tornado>=6.0.0; python_version >= '3.5'
zeroconf==0.19.*; python_version == '2.7'
zeroconf>=0.21.0; python_version >= '3.4'
zeroconf>=0.26.0; python_version >= '3.5'
22 changes: 7 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,15 @@
'zeroconf==0.19.*',
])
elif sys.version_info.major == 3:
if sys.version_info.minor < 5:
requirements.extend([
'jsonschema==2.6.*',
'tornado==5.1.*',
'zeroconf>=0.21.0',
])
else:
requirements.extend([
'jsonschema>=3.2.0',
'tornado>=6.0.0',
'zeroconf>=0.21.0',
])
requirements.extend([
'jsonschema>=3.2.0',
'tornado>=6.0.0',
'zeroconf>=0.26.0',
])

setup(
name='webthing',
version='0.12.2',
version='0.12.3',
description='HTTP Web Thing implementation',
long_description=long_description,
url='https://github.com/mozilla-iot/webthing-python',
Expand All @@ -53,7 +46,6 @@
'Intended Audience :: Developers',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand All @@ -64,5 +56,5 @@
'Source': 'https://github.com/mozilla-iot/webthing-python',
'Tracker': 'https://github.com/mozilla-iot/webthing-python/issues',
},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4',
)
78 changes: 46 additions & 32 deletions webthing/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,24 +504,31 @@ def post(self, thing_id='0'):
self.set_status(400)
return

response = {}
for action_name, action_params in message.items():
input_ = None
if 'input' in action_params:
input_ = action_params['input']
keys = list(message.keys())
if len(keys) != 1:
self.set_status(400)
return

action = thing.perform_action(action_name, input_)
if action:
response.update(action.as_action_description())
action_name = keys[0]
action_params = message[action_name]
input_ = None
if 'input' in action_params:
input_ = action_params['input']

# Start the action
tornado.ioloop.IOLoop.current().spawn_callback(
perform_action,
action,
)
action = thing.perform_action(action_name, input_)
if action:
response = action.as_action_description()

self.set_status(201)
self.write(json.dumps(response))
# Start the action
tornado.ioloop.IOLoop.current().spawn_callback(
perform_action,
action,
)

self.set_status(201)
self.write(json.dumps(response))
else:
self.set_status(400)


class ActionHandler(BaseHandler):
Expand Down Expand Up @@ -560,27 +567,34 @@ def post(self, thing_id='0', action_name=None):
self.set_status(400)
return

response = {}
for name, action_params in message.items():
if name != action_name:
continue
keys = list(message.keys())
if len(keys) != 1:
self.set_status(400)
return

if keys[0] != action_name:
self.set_status(400)
return

input_ = None
if 'input' in action_params:
input_ = action_params['input']
action_params = message[action_name]
input_ = None
if 'input' in action_params:
input_ = action_params['input']

action = thing.perform_action(name, input_)
if action:
response.update(action.as_action_description())
action = thing.perform_action(action_name, input_)
if action:
response = action.as_action_description()

# Start the action
tornado.ioloop.IOLoop.current().spawn_callback(
perform_action,
action,
)
# Start the action
tornado.ioloop.IOLoop.current().spawn_callback(
perform_action,
action,
)

self.set_status(201)
self.write(json.dumps(response))
self.set_status(201)
self.write(json.dumps(response))
else:
self.set_status(400)


class ActionIDHandler(BaseHandler):
Expand Down