I want to get the pid by passing in the user name. For example, in the picture of a macOS activity monitor, the user name is ‘root’, and I want something that can return all running processes under user name ‘root’. Answer Use psutil.process_iter() to get all running processes, and then filter them by matching psutil.Process.username() with the desired username.
Tag: psutil
Python script to check batterylevel on powerbank connected to Raspberry Pi
I have project that includes a Raspberry Pi connected to a powerbank as power source. In my python script I would like to check the battery status of the powerbank before starting a function. From what I’ve been able to look up on the internet there is no way this will work solely with a code and no additional parts(except