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

Re: [K12OSN] TeacherTool



Huck wrote:

below is the function I believe that you are looking for to tweak in TeacherTool...
not sure where the tweak would go for 'numbers' or not..
looks like it's reading the whole thing as a string so should come out right to begin with?
--Huck


<snip>
def populateList(self):
" Populates the list of user with unique user machines combinations "
self.listBox.deleteAll()
userList = []


#fd = os.popen("cat FakeData") # TESTING
fd = os.popen("netstat -t -e | grep x11 | sed -e 's/ \+/ /g' -e 's/:/ /g'") # REAL


       consoleOutput = fd.readlines()
       fd.close()
       self.listBox.deleteAll()
       for line in consoleOutput:
           lineParts = string.split(line)
           if len(lineParts) >= 9:
                machine = lineParts[5]
                user = lineParts[8]
           else:  # RH9 bug?
                machine = lineParts[3]
                user = lineParts[6]
           if (user != "root" and not user[0] in string.digits):
               userList.append(user+"@"+machine)

       userList = self.gu.uniqueItems(userList)
       userList.sort()
       for item in userList:
           self.listBox.add(item)
</snip>

I suspect the problem is this line:
if (user != "root" and not user[0] in string.digits):
Because it is testing that the first character in user is not a numeric digit.
What I do not know since there are no comments, is why lines with such user values were deliberately excluded in the first place.


Try changing it to this, but watch out whether you get other unexpected lines in the user list:
if (user != "root"):


Chris

--
-----------------------------------------------------------
  "Spend less!  Do more!  Go Open Source..." -- Dirigo.net
  Chris Johnson, RHCE #807000448202021


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