only use -it
for ttys
This commit is contained in:
parent
6bee27bb0d
commit
7f59891a4e
1 changed files with 46 additions and 17 deletions
63
blend
63
blend
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import glob
|
from sys import stdout
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
import socket
|
import socket
|
||||||
|
@ -238,14 +238,22 @@ def host_get_output(cmd): return subprocess.run(['bash', '-c', cmd],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
|
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL).stdout.decode('UTF-8').strip()
|
||||||
|
|
||||||
|
|
||||||
def core_get_retcode(cmd): return subprocess.run(['podman', 'exec', '--user', getpass.getuser(), '-it', args.container_name, 'bash', '-c', cmd],
|
def core_get_retcode(cmd):
|
||||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode
|
# only use `-it` if stdout is a tty
|
||||||
|
cmd = ['podman', 'exec', '--user', getpass.getuser(), '-it',
|
||||||
|
args.container_name, 'bash', '-c', cmd]
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
return subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode
|
||||||
|
|
||||||
|
|
||||||
def core_run_container(cmd):
|
def core_run_container(cmd):
|
||||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||||
subprocess.call(['podman', 'exec', '--user', getpass.getuser(),
|
# only use `-it` if stdout is a tty
|
||||||
'-w', os.getcwd(), '-it', args.container_name, 'bash', '-c', cmd])
|
cmd = ['podman', 'exec', '--user', getpass.getuser(),
|
||||||
|
'-w', os.getcwd(), '-it', args.container_name, 'bash', '-c', cmd]
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
|
||||||
|
subprocess.call(cmd)
|
||||||
|
|
||||||
|
|
||||||
def core_install_pkg(pkg):
|
def core_install_pkg(pkg):
|
||||||
|
@ -424,25 +432,46 @@ def enter_container():
|
||||||
if not os.environ.get('BLEND_COMMAND'):
|
if not os.environ.get('BLEND_COMMAND'):
|
||||||
if args.pkg == []:
|
if args.pkg == []:
|
||||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args,
|
# only use `-it` if stdout is a tty
|
||||||
'-w', os.getcwd(), '-it', args.container_name, 'bash']))
|
cmd = [*sudo, 'podman', 'exec', *podman_args,
|
||||||
|
'-w', os.getcwd(), '-it', args.container_name, 'bash']
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
exit(subprocess.call(cmd))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w',
|
# only use `-it` if stdout is a tty
|
||||||
'/run/host' + os.getcwd(), '-it', args.container_name, 'bash']))
|
cmd = [*sudo, 'podman', 'exec', *podman_args, '-w',
|
||||||
|
'/run/host' + os.getcwd(), '-it', args.container_name, 'bash']
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
exit(subprocess.call(cmd))
|
||||||
else:
|
else:
|
||||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args,
|
# only use `-it` if stdout is a tty
|
||||||
'-w', os.getcwd(), '-it', args.container_name, *args.pkg]))
|
cmd = [*sudo, 'podman', 'exec', *podman_args,
|
||||||
|
'-w', os.getcwd(), '-it', args.container_name, *args.pkg]
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
exit(subprocess.call(cmd))
|
||||||
else:
|
else:
|
||||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w',
|
# only use `-it` if stdout is a tty
|
||||||
'/run/host' + os.getcwd(), '-it', args.container_name, *args.pkg]))
|
cmd = [*sudo, 'podman', 'exec', *podman_args, '-w',
|
||||||
|
'/run/host' + os.getcwd(), '-it', args.container_name, *args.pkg]
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
exit(subprocess.call(cmd))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
if os.getcwd() == os.path.expanduser('~') or os.getcwd().startswith(os.path.expanduser('~') + '/'):
|
||||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w', os.getcwd(
|
# only use `-it` if stdout is a tty
|
||||||
), '-it', args.container_name, 'bash', '-c', os.environ.get('BLEND_COMMAND')]))
|
cmd = [*sudo, 'podman', 'exec', *podman_args, '-w', os.getcwd(), '-it',
|
||||||
|
args.container_name, 'bash', '-c', os.environ.get('BLEND_COMMAND')]
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
exit(subprocess.call(cmd))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
exit(subprocess.call([*sudo, 'podman', 'exec', *podman_args, '-w',
|
# only use `-it` if stdout is a tty
|
||||||
'/run/host' + os.getcwd(), '-it', args.container_name, 'bash']))
|
cmd = [*sudo, 'podman', 'exec', *podman_args, '-w',
|
||||||
|
'/run/host' + os.getcwd(), '-it', args.container_name, 'bash']
|
||||||
|
cmd = [x for x in cmd if x != '-it' or stdout.isatty()]
|
||||||
|
exit(subprocess.call(cmd))
|
||||||
|
|
||||||
|
|
||||||
def create_container():
|
def create_container():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue