sebastien / cuisine

Chef-like functionality for Fabric

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

process_find can't find processes due to leading spaces.

swstephe opened this issue · comments

I was going through the functions in cuisine.py to teach myself all the functions. When I got to "process_find", I noticed it failed to find some processes. It looks like lines need to be stripped before splitting on space if the process is in a range with fewer digits than the max pid. For example, "ps -A", on my Ubuntu/Mint Linux box returns these lines:

  8733 pts/5    00:00:00 bash
  9788 ?        00:00:13 gvim
 10740 ?        00:00:00 kworker/u4:1
 10913 ?        00:00:00 kworker/u4:0
 10993 ?        00:00:00 kworker/u4:2

There are leading spaces before the first 3 lines, so on line 884

>>> RE_SPACES.split(line, 3)
['', '9788', '?', '00:00:13 gvim']

... should probably be changed to:

>>> RE_SPACES.split(line.strip(), 3)
['9788', '?', '00:00:13', 'gvim']

Thanks for reporting, let me know if dba02f2ebc15290b8795ef49bc5c12937c32bbc8 solves it (git clone git@github.com:sebastien/cuisine.git ; cd cuisine ; python2.7 setup.py install).

Yes, that works for me. Thanks.

>>> process_find('gvim')
['9788', '11503', '11689', '11928', '12343']

Great, just bumped the release to 0.7.13