Remove duplicate run_with_tee.
This commit is contained in:
parent
b7f2f8dbe3
commit
f6f6b5a696
3 changed files with 16 additions and 24 deletions
|
@ -21,6 +21,7 @@ import stat
|
|||
import subprocess
|
||||
import sys
|
||||
from typing import List
|
||||
from .session import run_with_tee
|
||||
|
||||
|
||||
DEFAULT_PYTHON = 'python3'
|
||||
|
@ -59,18 +60,6 @@ def warning(m):
|
|||
sys.stderr.write('WARNING: %s\n' % m)
|
||||
|
||||
|
||||
def run_with_tee(session, args: List[str], **kwargs):
|
||||
p = session.Popen(
|
||||
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
|
||||
contents = []
|
||||
while p.poll() is None:
|
||||
line = p.stdout.readline()
|
||||
sys.stdout.buffer.write(line)
|
||||
sys.stdout.buffer.flush()
|
||||
contents.append(line.decode('utf-8', 'surrogateescape'))
|
||||
return p.returncode, contents
|
||||
|
||||
|
||||
def run_apt(session, args: List[str]) -> None:
|
||||
args = ['apt', '-y'] + args
|
||||
retcode, lines = run_with_tee(session, args, cwd='/', user='root')
|
||||
|
|
|
@ -33,6 +33,7 @@ from breezy.workingtree import WorkingTree
|
|||
|
||||
from breezy.plugins.debian.repack_tarball import get_filetype
|
||||
|
||||
from .session import run_with_tee
|
||||
from .debian.fix_build import (
|
||||
DependencyContext,
|
||||
resolve_error,
|
||||
|
@ -93,18 +94,6 @@ def satisfy_build_deps(session: Session, tree):
|
|||
apt_satisfy(session, deps)
|
||||
|
||||
|
||||
def run_with_tee(session: Session, args: List[str], **kwargs):
|
||||
p = session.Popen(
|
||||
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
|
||||
contents = []
|
||||
while p.poll() is None:
|
||||
line = p.stdout.readline()
|
||||
sys.stdout.buffer.write(line)
|
||||
sys.stdout.buffer.flush()
|
||||
contents.append(line.decode('utf-8', 'surrogateescape'))
|
||||
return p.returncode, contents
|
||||
|
||||
|
||||
class SchrootDependencyContext(DependencyContext):
|
||||
|
||||
def __init__(self, session):
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
from typing import Optional, List, Dict
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
class Session(object):
|
||||
|
@ -64,3 +66,15 @@ class Session(object):
|
|||
|
||||
class SessionSetupFailure(Exception):
|
||||
"""Session failed to be set up."""
|
||||
|
||||
|
||||
def run_with_tee(session: Session, args: List[str], **kwargs):
|
||||
p = session.Popen(
|
||||
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
|
||||
contents = []
|
||||
while p.poll() is None:
|
||||
line = p.stdout.readline()
|
||||
sys.stdout.buffer.write(line)
|
||||
sys.stdout.buffer.flush()
|
||||
contents.append(line.decode('utf-8', 'surrogateescape'))
|
||||
return p.returncode, contents
|
||||
|
|
Loading…
Add table
Reference in a new issue