From 2c8af1f85d8fabc67980f6ae8657d6082d6067c9 Mon Sep 17 00:00:00 2001 From: "Mario Izquierdo (mariodebian)" Date: Thu, 11 Nov 2010 12:34:10 +0100 Subject: New pref variable 'consolekit' to disable Sessions() search --- tcosmonitor/LocalData.py | 38 +++++++++++++++++++------------------- tcosmonitor/Sessions.py | 5 +++-- tcosmonitor/TcosPreferences.py | 3 +++ tcosmonitor/shared.py | 1 + 4 files changed, 26 insertions(+), 21 deletions(-) (limited to 'tcosmonitor') diff --git a/tcosmonitor/LocalData.py b/tcosmonitor/LocalData.py index 3b4d24f..2260909 100644 --- a/tcosmonitor/LocalData.py +++ b/tcosmonitor/LocalData.py @@ -505,22 +505,23 @@ class LocalData: hostname=self.GetHostname(ip) print_debug("GetLast() ip=%s hostname=%s "%(ip, hostname) ) - # try to connect with GDM througth dbus to read all - # sessions & display info, better than read wtmp - import tcosmonitor.Sessions - if os.path.isfile("/etc/dbus-1/system.d/gdm.conf"): - app=tcosmonitor.Sessions.Sessions() - for session in app.sessions: - if session.remote_host_name == ip: - print_debug("GetLast() session=%s"%session) - crono(start, "GetLast()") - data= {"pid":0, - "user":session.user, - "host":tcosmonitor.shared.parseIPAddress(session.remote_host_name), - "time":session.since, - "timelogged":session.diff, - "exclude":self.isLastExclude(session.user, ingroup)} - return data + if self.main.config.GetVar("consolekit") == 1: + # try to connect with GDM througth dbus to read all + # sessions & display info, better than read wtmp + if os.path.isfile("/etc/dbus-1/system.d/gdm.conf"): + from tcosmonitor.Sessions import Sessions + app=Sessions() + for session in app.sessions: + if session.remote_host_name == ip: + print_debug("GetLast() session=%s"%session) + crono(start, "GetLast()") + data= {"pid":0, + "user":session.user, + "host":tcosmonitor.shared.parseIPAddress(session.remote_host_name), + "time":session.since, + "timelogged":session.diff, + "exclude":self.isLastExclude(session.user, ingroup)} + return data for i in range(10): @@ -543,9 +544,8 @@ class LocalData: b.ut_host = half1 else: b.ut_host = uthost - print_debug(" ==> '%s' != '%s' ut_line=%s" %(str(tcosmonitor.shared.parseIPAddress(b.ut_host)), ip, b.ut_line) ) - if str(tcosmonitor.shared.parseIPAddress(b.ut_host)) == ip or \ - str(tcosmonitor.shared.parseIPAddress(b.ut_host)) == hostname: + #print_debug(" ==> '%s' != '%s' ut_line=%s" %(uthost, ip, b.ut_line) ) + if uthost == ip or uthost == hostname: if b.ut_line.startswith("pts/") or not \ os.path.isdir("/proc/%s"%b.ut_pid): continue diff --git a/tcosmonitor/Sessions.py b/tcosmonitor/Sessions.py index 4f37ba2..efa6062 100644 --- a/tcosmonitor/Sessions.py +++ b/tcosmonitor/Sessions.py @@ -264,9 +264,10 @@ class Connections(object): if __name__ == "__main__": # # search for last connection of user prueba -# app=ConsoleKitHistory('prueba', last=True) +# app=ConsoleKitHistory(None, last=False) +# from pprint import pprint # for con in app.data: -# print con +# pprint (con) # print "\n" diff --git a/tcosmonitor/TcosPreferences.py b/tcosmonitor/TcosPreferences.py index c397153..4f8c03c 100644 --- a/tcosmonitor/TcosPreferences.py +++ b/tcosmonitor/TcosPreferences.py @@ -101,6 +101,7 @@ class TcosPreferences: self.main.pref_systemprocess = self.ui.get_object('ck_systemprocess') self.main.pref_threadscontrol = self.ui.get_object('ck_threadscontrol') self.main.pref_enable_sslxmlrpc = self.ui.get_object('ck_enable_sslxmlrpc') + self.main.pref_consolekit = self.ui.get_object('ck_consolekit') self.main.pref_blockactioninthishost = self.ui.get_object('ck_blockactioninthishost') self.main.pref_notshowwhentcosmonitor = self.ui.get_object('ck_notshowwhentcosmonitor') self.main.pref_onlyshowtcos = self.ui.get_object('ck_onlyshowtcos') @@ -164,6 +165,7 @@ class TcosPreferences: self.read_checkbox(self.main.pref_systemprocess, "systemprocess") self.read_checkbox(self.main.pref_threadscontrol, "threadscontrol") self.read_checkbox(self.main.pref_enable_sslxmlrpc, "enable_sslxmlrpc") + self.read_checkbox(self.main.pref_consolekit, "consolekit") self.read_checkbox(self.main.pref_blockactioninthishost, "blockactioninthishost") self.read_checkbox(self.main.pref_notshowwhentcosmonitor, "notshowwhentcosmonitor") self.read_checkbox(self.main.pref_onlyshowtcos, "onlyshowtcos") @@ -347,6 +349,7 @@ class TcosPreferences: self.populate_checkboxes(self.main.pref_systemprocess, "systemprocess") self.populate_checkboxes(self.main.pref_threadscontrol, "threadscontrol") self.populate_checkboxes(self.main.pref_enable_sslxmlrpc, "enable_sslxmlrpc") + self.populate_checkboxes(self.main.pref_consolekit, "consolekit") self.populate_checkboxes(self.main.pref_blockactioninthishost, "blockactioninthishost") self.populate_checkboxes(self.main.pref_notshowwhentcosmonitor, "notshowwhentcosmonitor") self.populate_checkboxes(self.main.pref_onlyshowtcos, "onlyshowtcos") diff --git a/tcosmonitor/shared.py b/tcosmonitor/shared.py index 1e210ad..a7e088c 100644 --- a/tcosmonitor/shared.py +++ b/tcosmonitor/shared.py @@ -153,6 +153,7 @@ DefaultConfig=[ ["menugroups", 1, "int"], ["positions", "", "str"], ["show_about", 1, "int"], +["consolekit", 0, "int"], ] # -- cgit v1.2.3