[nanny] Add COM-Threading support
- From: Roberto Majadas <telemaco src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nanny] Add COM-Threading support
- Date: Sun, 23 Jan 2011 18:03:01 +0000 (UTC)
commit 15c159d6ca011192f23fb36ffd89f7983a4de360
Author: Roberto Majadas <roberto majadas openshine com>
Date: Thu Sep 23 21:10:24 2010 +0200
Add COM-Threading support
daemon/NannyService.py | 3 +++
daemon/src/Win32Top.py | 5 ++++-
daemon/src/Win32UsersManager.py | 3 ++-
3 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/daemon/NannyService.py b/daemon/NannyService.py
index be4366a..e1dd0b4 100644
--- a/daemon/NannyService.py
+++ b/daemon/NannyService.py
@@ -34,6 +34,7 @@ import win32service
import win32event
import servicemanager
+
#Add nanny module to python paths
if not hasattr(sys, "frozen") :
root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -73,6 +74,7 @@ class NannyService (win32serviceutil.ServiceFramework):
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_,''))
self.CheckForQuit()
+ pythoncom.CoInitialize()
self.main()
def CheckForQuit(self):
@@ -80,6 +82,7 @@ class NannyService (win32serviceutil.ServiceFramework):
if not retval == win32event.WAIT_TIMEOUT:
# Received Quit from Win32
reactor.stop()
+ pythoncom.CoUninitialize()
reactor.callLater(1.0, self.CheckForQuit)
diff --git a/daemon/src/Win32Top.py b/daemon/src/Win32Top.py
index 72e183b..a5cb615 100644
--- a/daemon/src/Win32Top.py
+++ b/daemon/src/Win32Top.py
@@ -22,6 +22,7 @@
import os
import time
+import win32api
import win32com.client
import gobject
from twisted.internet import reactor
@@ -34,7 +35,9 @@ class Win32Top(gobject.GObject) :
self.process_list = {}
self.session_user = 0
self.first_time = True
- self.oWMI = win32com.client.GetObject(r"winmgmts:\\.\root\cimv2")
+ computer_name = win32api.GetComputerName()
+ #self.oWMI = win32com.client.GetObject(r"winmgmts:\\%s\root\cimv2" % computer_name)
+ self.oWMI = win32com.client.GetObject(r"winmgmts:")
reactor.addSystemEventTrigger("before", "startup", self.start)
reactor.addSystemEventTrigger("before", "shutdown", self.stop)
diff --git a/daemon/src/Win32UsersManager.py b/daemon/src/Win32UsersManager.py
index c8e1f97..74b55db 100644
--- a/daemon/src/Win32UsersManager.py
+++ b/daemon/src/Win32UsersManager.py
@@ -37,7 +37,8 @@ class Win32UsersManager:
return self.users
users=[]
- oWMI = win32com.client.GetObject(r"winmgmts:\\.\root\cimv2")
+ #oWMI = win32com.client.GetObject(r"winmgmts:\\.\root\cimv2")
+ oWMI = win32com.client.GetObject(r"winmgmts:")
qry = "Select * from Win32_UserAccount Where LocalAccount = True and Disabled = False"
qry = oWMI.ExecQuery(qry)
if qry.count > 0:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]