fixed windows wmic result parsing
Description
In lock.py: changed
_, val = lines
to
val = lines[-1]
because it works with the current WMIC version and is generally less brittle.
Motivation and Context
https://github.com/spotify/luigi/issues/3050
I got the following error everytime I tried to run a luigi task:
ERROR: Uncaught exception in luigi
Traceback (most recent call last):
(...)
File "(...)\.venv\Lib\site-packages\luigi\lock.py", line 42, in getpcmd
_, val = lines
^^^^^^
ValueError: too many values to unpack (expected 2)
Have you tested this? If so, how?
Tested on Windows 11.
Quick googling uncovers that wmic has been deprecated since Windows 10, version 21H1 and replaced by a powershell command. When asking an AI assistant for the powershell equivalent of this command, it gave:
Get-CimInstance Win32_Process -Filter "ProcessId={pid}" | Select-Object CommandLine
Perhaps see if the following can be a replacement command:
cmd = f"powershell.exe -Command Get-CimInstance Win32_Process -Filter \"ProcessId={pid}\" | Select-Object CommandLine"
Note: this is untested.
Quick googling uncovers that
wmichas been deprecated sinceWindows 10, version 21H1and replaced by a powershell command. When asking an AI assistant for the powershell equivalent of this command, it gave:Get-CimInstance Win32_Process -Filter "ProcessId={pid}" | Select-Object CommandLinePerhaps see if the following can be a replacement command:
cmd = f"powershell.exe -Command Get-CimInstance Win32_Process -Filter \"ProcessId={pid}\" | Select-Object CommandLine"Note: this is untested.
Great thats even better, I added it