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
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
# SAT: a jabber client
|
# Libervia XMPP client
|
||||||
# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
|
# Copyright (C) 2009-2026 Jérôme Poisson (goffi@goffi.org)
|
||||||
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# 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
|
# 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):
|
class CommandProtocol(protocol.ProcessProtocol):
|
||||||
"""handle an external command"""
|
"""handle an external command"""
|
||||||
|
|
||||||
# name of the command (unicode)
|
# name of the command
|
||||||
name = None
|
name: str|None = None
|
||||||
# full path to the command (bytes)
|
# full path to the command
|
||||||
command = None
|
command: bytes|None = None
|
||||||
# True to activate logging of command outputs (bool)
|
# True to activate logging of command outputs
|
||||||
log = False
|
log: bool = False
|
||||||
|
|
||||||
def __init__(self, deferred, stdin=None):
|
def __init__(self, deferred, stdin=None):
|
||||||
"""
|
"""
|
||||||
|
|
@ -130,7 +130,8 @@ class CommandProtocol(protocol.ProcessProtocol):
|
||||||
"""
|
"""
|
||||||
stdin = kwargs.pop("stdin", None)
|
stdin = kwargs.pop("stdin", None)
|
||||||
if stdin is not None:
|
if stdin is not None:
|
||||||
stdin = stdin.encode("utf-8")
|
if isinstance(stdin, str):
|
||||||
|
stdin = stdin.encode()
|
||||||
verbose = kwargs.pop("verbose", False)
|
verbose = kwargs.pop("verbose", False)
|
||||||
args = list(args)
|
args = list(args)
|
||||||
d = defer.Deferred()
|
d = defer.Deferred()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue