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 subprocess
|
||||||
import sys
|
import sys
|
||||||
from typing import List
|
from typing import List
|
||||||
|
from .session import run_with_tee
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_PYTHON = 'python3'
|
DEFAULT_PYTHON = 'python3'
|
||||||
|
@ -59,18 +60,6 @@ def warning(m):
|
||||||
sys.stderr.write('WARNING: %s\n' % 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:
|
def run_apt(session, args: List[str]) -> None:
|
||||||
args = ['apt', '-y'] + args
|
args = ['apt', '-y'] + args
|
||||||
retcode, lines = run_with_tee(session, args, cwd='/', user='root')
|
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 breezy.plugins.debian.repack_tarball import get_filetype
|
||||||
|
|
||||||
|
from .session import run_with_tee
|
||||||
from .debian.fix_build import (
|
from .debian.fix_build import (
|
||||||
DependencyContext,
|
DependencyContext,
|
||||||
resolve_error,
|
resolve_error,
|
||||||
|
@ -93,18 +94,6 @@ def satisfy_build_deps(session: Session, tree):
|
||||||
apt_satisfy(session, deps)
|
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):
|
class SchrootDependencyContext(DependencyContext):
|
||||||
|
|
||||||
def __init__(self, session):
|
def __init__(self, session):
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
from typing import Optional, List, Dict
|
from typing import Optional, List, Dict
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
class Session(object):
|
class Session(object):
|
||||||
|
@ -64,3 +66,15 @@ class Session(object):
|
||||||
|
|
||||||
class SessionSetupFailure(Exception):
|
class SessionSetupFailure(Exception):
|
||||||
"""Session failed to be set up."""
|
"""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