Browse Source

set colours to be vars, to make it easier to fix this for no colour input

import/heads/master
Cian Brennan 11 years ago
parent
commit
c379f85822
1 changed files with 17 additions and 8 deletions
  1. +17
    -8
      rbusers.py

+ 17
- 8
rbusers.py View File

@@ -9,7 +9,14 @@ import pwd
users = utmp.UtmpRecord()
logged_users = {}
default_colour = '\033[;0m'
friend_colour = '\033[;37m'
white_text_escape = '\033[;37m'
white_back_escape = '\033[;47m'
red_back_escape = '\033[;41m'
cyan_back_escape = '\033[;46m'
green_back_escape = '\033[;42m'
magenta_back_escape = '\033[;45m'
yellow_back_escape = '\033[;43m'

for user in users :
n = user.ut_user
try :
@@ -25,12 +32,14 @@ friends = [ i.rstrip() for i in friends_file.readlines() ]
#http://old.nabble.com/Unable-to-see-os.environ-%27COLUMNS%27--td19487200.html
print '%s%s%s' % (' ' \
,'\033[;31mTotal \033[;0mNumber \033[;33mof \033[;34mUsers \033[;35monline\033[;0m:', len(logged_users) )
print '%s%s%s' % ( ' ', '\033[;47m \033[;0m friends', \
' \033[;41m \033[;0m committee \033[;46m \033[;0m associate' )
print '%s%s%s%s' % ( ' ', \
'\033[;45m \033[;0m society ',\
'\033[;43m \033[;0m club ',\
'\033[;42m \033[;0m guest' )
print '%s%s%s%s%s%s%s' % ( ' ',\
white_back_escape, ' \033[;0m friends ', \
red_back_escape, ' \033[;0m committee ',\
cyan_back_escape, ' \033[;0m associate' )
print '%s%s%s%s%s%s%s' % ( ' ', \
magenta_back_escape, ' \033[;0m society ',\
yellow_back_escape, ' \033[;0m club ',\
green_back_escape, ' \033[;0m guest' )
print
groups = { 100 : '\033[;31m', 107 : '\033[;36m', \
108 : '\033[;32m', 102 : '\033[;33m', 101 : '\033[;35m' }
@@ -39,7 +48,7 @@ print ' ',
for user in logged_users.keys() :
iter = iter + 1
if user in friends :
print ' %s%s (%d)' % (friend_colour, user.ljust(8), logged_users[user] ),
print ' %s%s (%d)' % (white_text_escape, user.ljust(8), logged_users[user] ),
else :
try :
group = pwd.getpwnam(user)[3]


Loading…
Cancel
Save