Skip to content

Commit

Permalink
Revert to subprocess.Popen since subprocess.call is the old API
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmj committed Nov 3, 2023
1 parent 0a81af8 commit 3a7e06e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions gns3/spice_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def spiceConsole(node, port, command):
log.debug('starting SPICE program "{}"'.format(command))
if sys.platform.startswith("win"):
# use the string on Windows
subprocess.call(command, env=os.environ)
subprocess.Popen(command, env=os.environ)
else:
# use arguments on other platforms
args = shlex.split(command)
subprocess.call(args, env=os.environ)
subprocess.Popen(args, env=os.environ)
except (OSError, ValueError, subprocess.SubprocessError) as e:
log.error("Could not start SPICE program with command '{}': {}".format(command, e))
4 changes: 2 additions & 2 deletions gns3/telnet_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def exec_command(self, command):

if sys.platform.startswith("win"):
# use the string on Windows
subprocess.call(command, env=os.environ)
subprocess.Popen(command, env=os.environ)
else:
# use arguments on other platforms
try:
Expand All @@ -102,7 +102,7 @@ def exec_command(self, command):
# inject gnome-terminal environment variables
if "GNOME_TERMINAL_SERVICE" not in env or "GNOME_TERMINAL_SCREEN" not in env:
env.update(gnome_terminal_env())
subprocess.call(args, env=env)
subprocess.Popen(args, env=env)

def run(self):

Expand Down
4 changes: 2 additions & 2 deletions gns3/vnc_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def vncConsole(node, port, command):
log.debug('starting VNC program "{}"'.format(command))
if sys.platform.startswith("win"):
# use the string on Windows
subprocess.call(command, env=os.environ)
subprocess.Popen(command, env=os.environ)
else:
# use arguments on other platforms
args = shlex.split(command)
subprocess.call(args, env=os.environ)
subprocess.Popen(args, env=os.environ)
except (OSError, ValueError, subprocess.SubprocessError) as e:
log.error("Could not start VNC program with command '{}': {}".format(command, e))
2 changes: 1 addition & 1 deletion tests/test_spice_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_spice_console_on_linux_and_mac(vpcs_device):

def test_spice_console_on_windows(vpcs_device):

with patch('subprocess.call') as p, \
with patch('subprocess.Popen') as p, \
patch('sys.platform', new="win"):
vpcs_device.settings()["console_host"] = "localhost"
spiceConsole(vpcs_device, '2525', 'command %h %p')
Expand Down
6 changes: 3 additions & 3 deletions tests/test_vnc_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

def test_vnc_console_on_linux_and_mac(vpcs_device):

with patch('subprocess.call') as p, \
with patch('subprocess.Popen') as p, \
patch('sys.platform', new="linux"):
vpcs_device.settings()["console_host"] = "localhost"
vncConsole(vpcs_device, 6000, 'command %h %p %D')
Expand All @@ -34,7 +34,7 @@ def test_vnc_console_on_linux_and_mac(vpcs_device):

def test_vnc_console_on_windows(vpcs_device):

with patch('subprocess.call') as p, \
with patch('subprocess.Popen') as p, \
patch('sys.platform', new="win"):
vpcs_device.settings()["console_host"] = "localhost"
vncConsole(vpcs_device, 6000, 'command %h %p %D')
Expand All @@ -44,7 +44,7 @@ def test_vnc_console_on_windows(vpcs_device):


# def test_vnc_console_on_linux_with_popen_issues(vpcs_device):
# with patch('subprocess.call', side_effect=subprocess.SubprocessError()), \
# with patch('subprocess.Popen', side_effect=subprocess.SubprocessError()), \
# patch('sys.platform', new="linux"):
# vpcs_device.settings()["console_host"] = "localhost"
#
Expand Down

0 comments on commit 3a7e06e

Please sign in to comment.