tools (common/async_process): accept Path instances as command path.

This commit is contained in:
Goffi 2024-06-20 14:47:09 +02:00
commit 17ae6ba241

View file

@ -20,6 +20,7 @@
"""tools to launch process in a async way (using Twisted)"""
import os.path
from pathlib import Path
from typing import Any
from twisted.internet import defer, reactor, protocol
from twisted.python.failure import Failure
@ -143,6 +144,8 @@ class CommandProtocol(protocol.ProcessProtocol):
"to execute as first argument"
)
command = args.pop(0)
if isinstance(command, Path):
command = str(command)
if prot.name is None:
name = os.path.splitext(os.path.basename(command))[0]
prot.name = name