tools (common/async_process): Accept bytes as stdin
This commit is contained in:
parent
77e2c9ce11
commit
c46f0716dc
1 changed files with 10 additions and 9 deletions
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
# SAT: a jabber client
|
||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
||||
# Libervia XMPP client
|
||||
# Copyright (C) 2009-2026 Jérôme Poisson (goffi@goffi.org)
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -34,12 +34,12 @@ log = getLogger(__name__)
|
|||
class CommandProtocol(protocol.ProcessProtocol):
|
||||
"""handle an external command"""
|
||||
|
||||
# name of the command (unicode)
|
||||
name = None
|
||||
# full path to the command (bytes)
|
||||
command = None
|
||||
# True to activate logging of command outputs (bool)
|
||||
log = False
|
||||
# name of the command
|
||||
name: str|None = None
|
||||
# full path to the command
|
||||
command: bytes|None = None
|
||||
# True to activate logging of command outputs
|
||||
log: bool = False
|
||||
|
||||
def __init__(self, deferred, stdin=None):
|
||||
"""
|
||||
|
|
@ -130,7 +130,8 @@ class CommandProtocol(protocol.ProcessProtocol):
|
|||
"""
|
||||
stdin = kwargs.pop("stdin", None)
|
||||
if stdin is not None:
|
||||
stdin = stdin.encode("utf-8")
|
||||
if isinstance(stdin, str):
|
||||
stdin = stdin.encode()
|
||||
verbose = kwargs.pop("verbose", False)
|
||||
args = list(args)
|
||||
d = defer.Deferred()
|
||||
|
|
|
|||
Loading…
Reference in a new issue