@@ -462,21 +462,25 @@ async def _close_job(cls, job_id, cancel_command):
462
462
logger .debug ("Closed job %s" , job_id )
463
463
464
464
@staticmethod
465
- async def _call (cmd , ** kwargs ):
465
+ async def _call (cmd , * , shell = False , * *kwargs ):
466
466
"""Call a command using asyncio.create_subprocess_exec.
467
467
468
468
This centralizes calls out to the command line, providing consistent
469
469
outputs, logging, and an opportunity to go asynchronous in the future.
470
470
471
471
Parameters
472
472
----------
473
- cmd: List(str))
473
+ cmd: List(str)
474
474
A command, each of which is a list of strings to hand to
475
475
asyncio.create_subprocess_exec
476
+ shell: bool
477
+ Use asyncio.create_subprocess_shell instead to run the command
478
+ in a shell?
476
479
477
480
Examples
478
481
--------
479
482
>>> self._call(['ls', '/foo'])
483
+ >>> self._call(['ls /foo'], shell=True)
480
484
481
485
Returns
482
486
-------
@@ -491,7 +495,12 @@ async def _call(cmd, **kwargs):
491
495
"Executing the following command to command line\n {}" .format (cmd_str )
492
496
)
493
497
494
- proc = await asyncio .create_subprocess_exec (
498
+ if shell :
499
+ create_subproc = asyncio .create_subprocess_shell
500
+ else :
501
+ create_subproc = asyncio .create_subprocess_exec
502
+
503
+ proc = await create_subproc (
495
504
* cmd ,
496
505
stdout = asyncio .subprocess .PIPE ,
497
506
stderr = asyncio .subprocess .PIPE ,
0 commit comments