From patchwork Mon Jul 29 01:38:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,2,STABLE] automation: execute powershell when connecting From: Gregory Szorc X-Patchwork-Id: 41092 Message-Id: <5d734ed277d9d1467dd3.1564364338@ubuntu-vm-main> To: mercurial-devel@mercurial-scm.org Date: Sun, 28 Jul 2019 18:38:58 -0700 # HG changeset patch # User Gregory Szorc # Date 1564363951 25200 # Sun Jul 28 18:32:31 2019 -0700 # Branch stable # Node ID 5d734ed277d9d1467dd32acaf9e04e1aa60bb9dd # Parent 9905d2b89f8ca2f542cd79986a0daf4bd72766d1 automation: execute powershell when connecting For some reason, the ability to execute PS scripts appears to come online after the ability to execute regular command scripts. This is creating race conditions when connecting to instances resulting in our wait_for_winrm() returning before PS is available leading to an exception being thrown in other code. Let's change the client connection code to execute a minimal PS script so we can try to trap the exception in wait_for_winrm(). diff --git a/contrib/automation/hgautomation/winrm.py b/contrib/automation/hgautomation/winrm.py --- a/contrib/automation/hgautomation/winrm.py +++ b/contrib/automation/hgautomation/winrm.py @@ -37,7 +37,7 @@ def wait_for_winrm(host, username, passw try: client = Client(host, username=username, password=password, ssl=ssl, connection_timeout=5) - client.execute_cmd('echo "hello world"') + client.execute_ps("Write-Host 'Hello, World!'") return client except requests.exceptions.ConnectionError: if time.time() >= end_time: