Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

Commit a20fe25

Browse files
committed
Minor enhancements
1 parent 01a70b1 commit a20fe25

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## Change Log
22

3+
#0.2.3
4+
Minor enhancements (including the workflow find() method)
5+
36
#0.2.2
47
New version scheme management
58

zenaton/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.2'
1+
__version__ = '0.2.3'

zenaton/client.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def send_event_url(self):
7878
:params .abstracts.workflow.Workflow flow
7979
"""
8080
def start_workflow(self, flow):
81-
self.http.post(self.instance_worker_url(),
82-
data=json.dumps({
81+
return self.http.post(self.instance_worker_url(),
82+
data=json.dumps({
8383
self.ATTR_PROG: self.PROG,
8484
self.ATTR_CANONICAL: self.canonical_name(flow),
8585
self.ATTR_NAME: self.class_name(flow),
@@ -95,7 +95,7 @@ def update_instance(self, workflow, custom_id, mode):
9595
self.ATTR_NAME: workflow.__name__,
9696
self.ATTR_MODE: mode
9797
})
98-
self.http.put(url, options)
98+
return self.http.put(url, options)
9999

100100
"""
101101
Sends an event to a workflow
@@ -112,7 +112,7 @@ def send_event(self, workflow_name, custom_id, event):
112112
self.EVENT_NAME: type(event).__name__,
113113
self.EVENT_INPUT: '{\"o\":\"@zenaton#0\",\"s\":[{\"a\":{}}]}',
114114
})
115-
self.http.post(self.send_event_url(), body)
115+
return self.http.post(self.send_event_url(), body)
116116

117117
"""
118118
Finds a workflow
@@ -149,7 +149,7 @@ def find_workflow(self, workflow, custom_id):
149149
:returns None
150150
"""
151151
def kill_workflow(self, workflow_name, custom_id):
152-
self.update_instance(workflow_name, custom_id, self.WORKFLOW_KILL)
152+
return self.update_instance(workflow_name, custom_id, self.WORKFLOW_KILL)
153153

154154
"""
155155
Pauses a workflow
@@ -158,7 +158,7 @@ def kill_workflow(self, workflow_name, custom_id):
158158
:returns None
159159
"""
160160
def pause_workflow(self, workflow_name, custom_id):
161-
self.update_instance(workflow_name, custom_id, self.WORKFLOW_PAUSE)
161+
return self.update_instance(workflow_name, custom_id, self.WORKFLOW_PAUSE)
162162

163163
"""
164164
Resumes a workflow
@@ -167,7 +167,7 @@ def pause_workflow(self, workflow_name, custom_id):
167167
:returns None
168168
"""
169169
def resume_workflow(self, workflow_name, custom_id):
170-
self.update_instance(workflow_name, custom_id, self.WORKFLOW_RUN)
170+
return self.update_instance(workflow_name, custom_id, self.WORKFLOW_RUN)
171171

172172
def instance_website_url(self, params=''):
173173
return self.website_url('instances', params)
@@ -182,12 +182,12 @@ def add_app_env(self, url, params):
182182

183183
def parse_custom_id_from(self, flow):
184184
custom_id = flow.id()
185-
if custom_id:
185+
if custom_id is not None:
186186
if not isinstance(custom_id, str) and not isinstance(custom_id, int):
187187
raise InvalidArgumentError('Provided ID must be a string or an integer')
188188
custom_id = str(custom_id)
189189
if len(custom_id) > self.MAX_ID_SIZE:
190-
raise InvalidArgumentError('Provided Id must not exceed {} bytes'.format_map(self.MAX_ID_SIZE))
190+
raise InvalidArgumentError('Provided Id must not exceed {} bytes'.format(self.MAX_ID_SIZE))
191191
return custom_id
192192

193193
def canonical_name(self, flow):

zenaton/services/http_service.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def request(self, method, url, headers, data=None):
3434
if r.status_code >= 400:
3535
raise InternalError(r.content)
3636
content = r.json()
37+
content['status_code'] = r.status_code
3738
except json.decoder.JSONDecodeError:
3839
raise InternalError
3940
except requests.exceptions.ConnectionError:

zenaton/tasks/wait.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ def __init__(self, event=None):
1818

1919
@property
2020
def error(self):
21-
return '{}: Invalid parameter - argument must be a Zenaton::Interfaces::Event subclass'.format(
21+
return '{}: Invalid parameter - argument must be a zenaton.abstracts.event.Event subclass'.format(
2222
self.__class__.__name__)
2323

2424
def handle(self):
2525
pass
2626

2727
def valid_param(self, event):
28-
return not hasattr(self, 'event') or isinstance(event, str) or self.event_class(event)
28+
return not event or isinstance(event, str) or self.event_class(event)
2929

3030
def event_class(self, event):
3131
return inspect.isclass(event) and issubclass(event, Event)

0 commit comments

Comments
 (0)