users.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 import subprocess
4 import threading
5 import time
6 import roslib
7 
8 class Users(roslib.message.Message):
9  __slots__ = ('users',)
10  def __init__(self, users):
11  self.users = users
12 
13 class UsersThread(threading.Thread):
14  def __init__(self):
15  threading.Thread.__init__(self)
16 
17  self.callback = None
18 
19  def setCallback(self, callback):
20  self.callback = callback
21 
22  def getUsers(self):
23  p = subprocess.Popen(['users'], stdout=subprocess.PIPE)
24  line = p.stdout.readline().strip()
25  parts = line.split()
26  users = {}
27  map(users.__setitem__, parts, [])
28  users = users.keys()
29  users.sort()
30  users = tuple(users)
31 
32  return users
33 
34  def run(self):
35  lastusers = ()
36  while 1:
37  try:
38  users = self.getUsers()
39  if users != lastusers:
40  lastusers = users
41  self.callback(Users(users))
42  except:
43  pass
44  time.sleep(3)
45 
46 
def __init__(self)
Definition: users.py:14
def setCallback(self, callback)
Definition: users.py:19
def __init__(self, users)
Definition: users.py:10
def run(self)
Definition: users.py:34
def getUsers(self)
Definition: users.py:22


rosweb
Author(s): Scott Noob Hassan, Rob Wheeler, Nate Koenig
autogenerated on Mon Jun 10 2019 15:51:19