本文整理汇总了Python中dockerpty.pty.PseudoTerminal.sockets方法的典型用法代码示例。如果您正苦于以下问题:Python PseudoTerminal.sockets方法的具体用法?Python PseudoTerminal.sockets怎么用?Python PseudoTerminal.sockets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dockerpty.pty.PseudoTerminal
的用法示例。
在下文中一共展示了PseudoTerminal.sockets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_one_off_container
# 需要导入模块: from dockerpty.pty import PseudoTerminal [as 别名]
# 或者: from dockerpty.pty.PseudoTerminal import sockets [as 别名]
def run_one_off_container(container_options, project, service, options):
if not options['--no-deps']:
deps = service.get_dependency_names()
if deps:
project.up(
service_names=deps,
start_deps=True,
strategy=ConvergenceStrategy.never,
rescale=False
)
project.initialize()
container = service.create_container(
quiet=True,
one_off=True,
**container_options)
if options['-d']:
service.start_container(container)
print(container.name)
return
def remove_container(force=False):
if options['--rm']:
project.client.remove_container(container.id, force=True, v=True)
signals.set_signal_handler_to_shutdown()
try:
try:
if IS_WINDOWS_PLATFORM:
service.connect_container_to_networks(container)
exit_code = call_docker(["start", "--attach", "--interactive", container.id])
else:
operation = RunOperation(
project.client,
container.id,
interactive=not options['-T'],
logs=False,
)
pty = PseudoTerminal(project.client, operation)
sockets = pty.sockets()
service.start_container(container)
pty.start(sockets)
exit_code = container.wait()
except signals.ShutdownException:
project.client.stop(container.id)
exit_code = 1
except signals.ShutdownException:
project.client.kill(container.id)
remove_container(force=True)
sys.exit(2)
remove_container()
sys.exit(exit_code)
示例2: run_one_off_container
# 需要导入模块: from dockerpty.pty import PseudoTerminal [as 别名]
# 或者: from dockerpty.pty.PseudoTerminal import sockets [as 别名]
def run_one_off_container(container_options, project, service, options):
if not options['--no-deps']:
deps = service.get_linked_service_names()
if deps:
project.up(
service_names=deps,
start_deps=True,
strategy=ConvergenceStrategy.never)
project.initialize()
container = service.create_container(
quiet=True,
one_off=True,
**container_options)
if options['-d']:
service.start_container(container)
print(container.name)
return
def remove_container(force=False):
if options['--rm']:
project.client.remove_container(container.id, force=True)
signals.set_signal_handler_to_shutdown()
try:
try:
pty = PseudoTerminal(
project.client,
container.id,
interactive=not options['-T'],
logs=False,
)
sockets = pty.sockets()
service.start_container(container)
pty.start(sockets)
exit_code = container.wait()
except signals.ShutdownException:
project.client.stop(container.id)
exit_code = 1
except signals.ShutdownException:
project.client.kill(container.id)
remove_container(force=True)
sys.exit(2)
remove_container()
sys.exit(exit_code)