aboutsummaryrefslogtreecommitdiffstats
path: root/task
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2021-09-07 14:02:34 -0500
committerGitHub <noreply@github.com>2021-09-07 22:02:34 +0300
commit92dccd0751fe3522095ab2eecb76efc696fb84d4 (patch)
treeb47df55a44873a750e22bef53476e4f6bfdd708e /task
parentRelease version 1.8.1 (diff)
downloadtaskipy2-92dccd0751fe3522095ab2eecb76efc696fb84d4.zip
Only use and install `mslex` on Windows (#36)
* Fix lint issues where encoding was not specified * Only use and install mslex on Windows * Escape backslash in test_windows * Alter Windows CI name Since we actually have some tests other than the path sanity test, it probably makes sense to just call it a Windows test now. * Disable pylint issue with mslex import It's raising an unable to import issue with that line, which makes sense since mslex wouldn't be installed on any other platform other than Windows, but it also wouldn't be run on any other platform so it seems to be a non issue. Co-authored-by: Eugene Triguba <etriguba@sonifi.com>
Diffstat (limited to '')
-rw-r--r--taskipy/task_runner.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/taskipy/task_runner.py b/taskipy/task_runner.py
index 0aa3aa1..fb3f806 100644
--- a/taskipy/task_runner.py
+++ b/taskipy/task_runner.py
@@ -3,8 +3,6 @@ import platform
import psutil # type: ignore
import signal
import subprocess
-import shlex
-import mslex # type: ignore
from pathlib import Path
from typing import List, Union, Optional
@@ -13,6 +11,11 @@ from taskipy.exceptions import TaskNotFoundError
from taskipy.task import Task
from taskipy.help import HelpFormatter
+if platform.system() == 'Windows':
+ import mslex as shlex # type: ignore # pylint: disable=E0401
+else:
+ import shlex # type: ignore[no-redef]
+
class TaskRunner:
def __init__(self, cwd: Union[str, Path]):
@@ -56,11 +59,6 @@ class TaskRunner:
if self.__project.runner is not None:
command = f'{self.__project.runner} {command}'
- def quote_arg(arg: str) -> str:
- if platform.system() == 'Windows':
- return mslex.quote(arg)
- return shlex.quote(arg)
-
def send_signal_to_task_process(signum: int, _frame) -> None:
# pylint: disable=W0640
psutil_process_wrapper = psutil.Process(process.pid)
@@ -75,7 +73,7 @@ class TaskRunner:
else:
process.send_signal(signum)
- command_with_args = ' '.join([command] + [quote_arg(arg) for arg in args])
+ command_with_args = ' '.join([command] + [shlex.quote(arg) for arg in args])
process = subprocess.Popen(command_with_args,
shell=True,
cwd=self.__working_dir)