|
16 | 16 | """GraphQL resolvers for use in data accessing and mutation of workflows.""" |
17 | 17 |
|
18 | 18 | import asyncio |
| 19 | +from enum import Enum |
19 | 20 | import errno |
20 | 21 | import os |
21 | 22 | import signal |
@@ -137,6 +138,8 @@ def _build_cmd(cmd: List, args: Dict) -> List: |
137 | 138 | if isinstance(value, int) and not isinstance(value, bool): |
138 | 139 | # Any integer items need converting to strings: |
139 | 140 | value = str(value) |
| 141 | + elif isinstance(value, Enum): |
| 142 | + value = value.value |
140 | 143 | value = [value] |
141 | 144 | for item in value: |
142 | 145 | cmd.append(key) |
@@ -257,8 +260,8 @@ async def clean( |
257 | 260 | elif isinstance(exc, WorkflowFilesError): # Expected error |
258 | 261 | msg = str(exc) |
259 | 262 | else: # Unexpected error |
| 263 | + log.exception(exc) |
260 | 264 | msg = f"{type(exc).__name__}: {exc}" |
261 | | - log.exception(msg) |
262 | 265 | return cls._error(msg) |
263 | 266 |
|
264 | 267 | # trigger a re-scan |
@@ -286,14 +289,9 @@ async def play( |
286 | 289 | cylc_version = args.pop('cylc_version', None) |
287 | 290 | results: Dict[str, str] = {} |
288 | 291 | failed = False |
289 | | - if 'mode' in args: |
290 | | - args['mode'] = args['mode'].value.value |
291 | 292 | for tokens in workflows: |
292 | 293 | try: |
293 | | - cmd = _build_cmd( |
294 | | - ['cylc', 'play', '--color=never'], |
295 | | - args |
296 | | - ) |
| 294 | + cmd = _build_cmd(['cylc', 'play', '--color=never'], args) |
297 | 295 |
|
298 | 296 | if tokens['user'] and tokens['user'] != getuser(): |
299 | 297 | return cls._error( |
@@ -335,8 +333,9 @@ async def play( |
335 | 333 | failed = True |
336 | 334 | else: |
337 | 335 | results[wflow] = 'started' |
| 336 | + |
338 | 337 | except Exception as exc: |
339 | | - # oh noes, something went wrong, send back confirmation |
| 338 | + log.exception(exc) |
340 | 339 | return cls._error(exc) |
341 | 340 |
|
342 | 341 | if failed: |
|
0 commit comments