fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] "Other users are logged in" messages being captured by ru


From: 686f6c6d
Subject: Re: [Fab-user] "Other users are logged in" messages being captured by run()
Date: Tue, 18 Dec 2012 21:00:26 +0100

(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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]