Skip to content

Commit

Permalink
fix: only hookup stdin on windows for dcm login (#271)
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Anderson <119458760+AWS-Samuel@users.noreply.github.com>
  • Loading branch information
AWS-Samuel committed Mar 31, 2024
1 parent 9c02f90 commit cb91b2c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
16 changes: 10 additions & 6 deletions src/deadline/client/api/_loginout.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ def _login_deadline_cloud_monitor(

# Open Deadline Cloud Monitor, non-blocking the user will keep Deadline Cloud Monitor running in the background.
try:
# We don't hookup to stdin but do this to avoid issues on windows
# See https://docs.python.org/3/library/subprocess.html#subprocess.STARTUPINFO.lpAttributeList

p = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE
)
if sys.platform.startswith("win"):
# We don't hookup to stdin but do this to avoid issues on windows
# See https://docs.python.org/3/library/subprocess.html#subprocess.STARTUPINFO.lpAttributeList
p = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE
)
else:
p = subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL
)
# Linux takes time to start DCM binary, which causes the TTY to suspend the process and send it to background job
# With wait here, the DCM binary starts and TTY does not suspend the deadline process.
if sys.platform == "linux":
Expand Down
22 changes: 16 additions & 6 deletions test/unit/deadline_client/cli/test_cli_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"""
import json
import subprocess
import sys

from unittest.mock import patch

from click.testing import CliRunner
Expand Down Expand Up @@ -45,12 +47,20 @@ def test_cli_deadline_cloud_monitor_login_and_logout(fresh_deadline_config):

assert result.exit_code == 0, result.output

popen_mock.assert_called_once_with(
["/bin/DeadlineCloudMonitor", "login", "--profile", "sandbox-us-west-2"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
)
if sys.platform.startswith("win"):
popen_mock.assert_called_once_with(
["/bin/DeadlineCloudMonitor", "login", "--profile", "sandbox-us-west-2"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.PIPE,
)
else:
popen_mock.assert_called_once_with(
["/bin/DeadlineCloudMonitor", "login", "--profile", "sandbox-us-west-2"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
stdin=subprocess.DEVNULL,
)

assert result.exit_code == 0

Expand Down

0 comments on commit cb91b2c

Please sign in to comment.