I have a set of directories on my machine related to PCI devices (GPUs). Within these directories are various hwmon
interfaces. I am attempting to find
the specific path for each PCI device by running the command, for example,
$ find /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/hwmon/hwmon* -maxdepth 0
Here the wildcard will match the single directory located under .../hwmon/
for each PCI device. The above command outputs the following in my terminal
/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/hwmon/hwmon2
I am attempting to automate this process in python with subprocess.run
subprocess.run('find', gpu_pci_device_path + '/hwmon/hwmon*', '-maxdepth', '0', stdout=subprocess.PIPE).stdout.decode('utf-8')
Here I have already located (what I have termed) the PCI device path for each GPU in the variable gpu_pci_device_path
. Then I am build the rest of the wildcard path to pass to find
.
Though it seems subprocess
is encasing the path I have built in single quotes based on the error it produces
find: ‘/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/hwmon/hwmon*’: No such file or directory
Thus it is negating my wildcard expression during find
. How can I supply this wildcard expression to find
during the call to subprocess.run
?
My evidence that the encasing is happening and the wildcard is negated is from the output of the command
$ find '/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/hwmon/hwmon*' -maxdepth 0
find: ‘/sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:00.0/0000:03:00.0/hwmon/hwmon*’: No such file or directory