luigi icon indicating copy to clipboard operation
luigi copied to clipboard

fixed windows wmic result parsing

Open bainewedlock opened this issue 8 months ago • 2 comments

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.

bainewedlock avatar Aug 26 '25 07:08 bainewedlock

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.

dlstadther avatar Aug 27 '25 00:08 dlstadther

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.

Great thats even better, I added it

bainewedlock avatar Aug 27 '25 06:08 bainewedlock