← Back to team overview

epoptes team mailing list archive

[Merge] lp:~oiteam/epoptes/seat-label into lp:epoptes

 

Laércio de Sousa has proposed merging lp:~oiteam/epoptes/seat-label into lp:epoptes.

Requested reviews:
  Epoptes Developers (epoptes)

For more details, see:
https://code.launchpad.net/~oiteam/epoptes/seat-label/+merge/243990

If XDG_SEAT PAM environment variable is set in user session (e.g. if systemd-logind is running), show seat name appended to hostname in clients' labels.
-- 
Your team Epoptes Developers is requested to review the proposed merge of lp:~oiteam/epoptes/seat-label into lp:epoptes.
=== modified file 'data/client-functions'
--- data/client-functions	2013-11-03 20:44:59 +0000
+++ data/client-functions	2014-12-08 12:57:18 +0000
@@ -64,12 +64,17 @@
                 | sed "s/.* \([0-9.]*\)\/.*/\\1/")
             test -n "$IP" || die "Empty IP"
         fi
+        if [ -n "$XDG_SEAT" ]; then
+            SEAT="$XDG_SEAT"
+        else
+            SEAT=""
+        fi
         CPU=$(cat /proc/cpuinfo | grep "^model name" | head -n 1 | sed "s/.*: //")
         RAM=$(free -m | grep "^Mem" | awk '{print $2}')
         VGA=$(lspci -nn -m | sed -n -e '/"VGA/s/[^"]* "[^"]*" "[^"]*" "\([^"]*\)" .*/\1/p' | tr '\n' ' ')
         OS=$(uname -o)
 
-        export VERSION USER NAME HOME HOSTNAME MAC IP CPU RAM VGA OS
+        export VERSION USER NAME HOME HOSTNAME MAC IP SEAT CPU RAM VGA OS
         cached_info=true
     fi
     cat <<EOF
@@ -82,6 +87,7 @@
 hostname=$HOSTNAME
 mac=$MAC
 ip=$IP
+seat=$SEAT
 cpu=$CPU
 ram=$RAM
 vga=$VGA

=== modified file 'epoptes/core/structs.py'
--- epoptes/core/structs.py	2012-03-04 16:24:00 +0000
+++ epoptes/core/structs.py	2014-12-08 12:57:18 +0000
@@ -56,8 +56,8 @@
     def set_name(self, name):
         self.alias = name
         
-    def add_user(self, username, realname, handle):
-        self.users[handle] = {'uname' : username, 'rname' : realname}
+    def add_user(self, username, realname, seat, handle):
+        self.users[handle] = {'uname' : username, 'rname' : realname, 'seat' : seat}
 
 
 class Group:

=== modified file 'epoptes/ui/gui.py'
--- epoptes/ui/gui.py	2014-05-17 03:44:40 +0000
+++ epoptes/ui/gui.py	2014-12-08 12:57:18 +0000
@@ -582,7 +582,7 @@
                 label = 'rname'
         if client.users:
             for hsession, user in client.users.iteritems():
-                self.cstore.append([self.calculateLabel(client, user[label]), self.imagetypes[client.type], client, hsession])
+                self.cstore.append([self.calculateLabel(client, user[label], user['seat']), self.imagetypes[client.type], client, hsession])
                 self.askScreenshot(hsession, True)
         else:
             self.cstore.append([self.calculateLabel(client), self.imagetypes[client.type], client, ''])
@@ -631,7 +631,7 @@
                 key, value = line.split('=', 1)
                 info[key.strip()] = value.strip()
             user, host, ip, mac, type, uid, version, name = \
-                info['user'], info['hostname'], info['ip'], info['mac'], \
+                info['user'], info['hostname'], info['ip'], info['seat'], info['mac'], \
                 info['type'], int(info['uid']), info['version'], info['name']
         except:
             print "Can't extract client information, won't add this client"
@@ -681,8 +681,8 @@
             client.hsystem = handle
         else:
             # This is a user epoptes-client
-            print '* I am a user client, will add', user, 'in my list'
-            client.add_user(user, name, handle)
+            print '* I am a user client, will add', user, 'at seat', seat, 'in my list'
+            client.add_user(user, name, seat, handle)
             if not already and (sel_group.has_client(client) or self.isDefaultGroupSelected()):
                 loginNotify(user, host)
         
@@ -697,18 +697,23 @@
             if self.showRealNames:
                 label = 'rname'
             user = row[C_INSTANCE].users[row[C_SESSION_HANDLE]][label]
+            seat = row[C_INSTANCE].users[row[C_SESSION_HANDLE]]['seat']
         else:
             user = ''
-        row[C_LABEL] = self.calculateLabel(inst, user)
-
-
-    def calculateLabel(self, client, username=''):
+            seat = ''
+        row[C_LABEL] = self.calculateLabel(inst, user, seat)
+
+
+    def calculateLabel(self, client, username='', seat=''):
         """Return the iconview label from a hostname/alias
         and a username, according to the user options.
         """
         user_pos, name_pos = self.cView_order
         
         alias = client.get_name()
+        if alias != client.mac and seat != '':
+            alias += '|' + seat
+
         if username == '' or user_pos == -1:
             return alias
         else: