(Sorry, forgot to reply to the list, too.)

I also can't tell you how those strings appear, but you can easily
work around it; you can do something like the following, for example.
If replace() or sub() don't find a match (when no other users are
logged in), the string remains unchanged.

---------- 8< ----------
import re

foo = run('some command')
print('debug #1: %s' % foo)

foo = foo.replace('Other users are logged in\n','')
print('debug #2: %s' % foo)

foo = 
re.sub(r'[a-z]+\s+pts/\d+\s+\d{4}-\d{1,2}-\d{1,2}\s+\d{1,2}:\d{2}\s+\(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\)\n','',foo)
print('debug #3: %s' % foo)
---------- >8 ----------

The regex is a bit coarse (as are my python skills), but it should work.


-- 
Kind regards
    Christopher 'm4z' Holm / 686f6c6d

"We must respect the other fellow's religion, but only in the sense
and to the extent that we respect his theory that his wife is
beautiful and his children smart." --H. L. Mencken

_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to