mirror of https://github.com/n1nj4sec/pupy.git
Colorize output depending on idle
This commit is contained in:
parent
8be925b74c
commit
398542404b
|
@ -31,14 +31,24 @@ class WModule(PupyModule):
|
|||
for user, hosts in reversed(sorted(data.iteritems())):
|
||||
for host, sessions in hosts.iteritems():
|
||||
for session in sessions:
|
||||
color = ""
|
||||
|
||||
if 'idle' in session:
|
||||
idle = session['idle']
|
||||
color = "cyan" if idle < 10*60 else (
|
||||
"grey" if idle > 60*60*24 else ""
|
||||
)
|
||||
|
||||
object = {
|
||||
'HOST': host,
|
||||
'HOST': colorize(host, color),
|
||||
'USER': colorize(
|
||||
user,
|
||||
"yellow" if user in ADMINS else (
|
||||
"green" if session.get('me') else "")
|
||||
),
|
||||
'LOGIN': str(datetime.fromtimestamp(int(session['started']))),
|
||||
'LOGIN': colorize(
|
||||
str(datetime.fromtimestamp(int(session['started']))), color
|
||||
),
|
||||
}
|
||||
|
||||
if session.get('terminal'):
|
||||
|
@ -51,9 +61,9 @@ class WModule(PupyModule):
|
|||
what = ''
|
||||
|
||||
object.update({
|
||||
'IDLE': str(timedelta(seconds=session['idle'])),
|
||||
'PID': session.get('pid', ''),
|
||||
'WHAT': what
|
||||
'IDLE': colorize(str(timedelta(seconds=session['idle'])), color),
|
||||
'PID': colorize(str(session.get('pid', '')), color),
|
||||
'WHAT': colorize(what, color)
|
||||
})
|
||||
|
||||
tablein.append(object)
|
||||
|
@ -62,7 +72,3 @@ class WModule(PupyModule):
|
|||
|
||||
except Exception, e:
|
||||
logging.exception(e)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue