[nanny] Fix some win32 bugs



commit cb9a2ecf6bf7e3dec079eb76bebe4a2256ccaf7c
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Wed Sep 15 13:57:17 2010 +0200

    Fix some win32 bugs

 daemon/nanny-daemon-win.py             |   23 +++++++++++++++++++++--
 daemon/src/Daemon.py                   |    5 ++++-
 daemon/src/FilterManager.py            |    2 +-
 daemon/src/Win32Chrono.py              |    3 ---
 daemon/src/Win32SessionFiltering.py    |    6 ++++--
 daemon/src/Win32UsersManager.py        |    2 +-
 daemon/src/Win32WebContentFiltering.py |    2 ++
 daemon/src/__init__.py                 |    3 ++-
 8 files changed, 35 insertions(+), 11 deletions(-)
---
diff --git a/daemon/nanny-daemon-win.py b/daemon/nanny-daemon-win.py
index 300dd63..eec12c5 100644
--- a/daemon/nanny-daemon-win.py
+++ b/daemon/nanny-daemon-win.py
@@ -20,10 +20,29 @@
 import os
 import sys
 
+# Reactor stuff
+from twisted.application import app, service
+import twisted.internet.gtk2reactor
+twisted.internet.gtk2reactor.install()
+from twisted.internet import reactor
+reactor.suggestThreadPoolSize(30)
+
 #Add nanny module to python paths
 root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 nanny_lib_path = os.path.join(root_path, "lib", "python2.6", "site-packages")
 sys.path.append(nanny_lib_path)
 
-print sys.path
-import nanny
+
+#Start UP application
+import nanny.daemon
+application = service.Application('nanny')
+daemon = nanny.daemon.Daemon(application)
+
+app_service = service.IService(application)
+app_service.privilegedStartService()
+app_service.startService()
+reactor.addSystemEventTrigger('before', 'shutdown',
+                              app_service.stopService)
+
+#Reactor Run
+reactor.run()
diff --git a/daemon/src/Daemon.py b/daemon/src/Daemon.py
index 622b875..4fd184e 100644
--- a/daemon/src/Daemon.py
+++ b/daemon/src/Daemon.py
@@ -23,8 +23,11 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 # USA
 
+import os
 from QuarterBack import QuarterBack
-from NannyDBus import NannyDBus
+
+if os.name == "posix":
+    from NannyDBus import NannyDBus
 
 import nanny.daemon.proxy
 
diff --git a/daemon/src/FilterManager.py b/daemon/src/FilterManager.py
index 032546a..e8c5a8b 100644
--- a/daemon/src/FilterManager.py
+++ b/daemon/src/FilterManager.py
@@ -65,7 +65,7 @@ elif os.name == "nt" :
 
 def mkdir_path(path):
     try:
-        os.mkdirs(path)
+        os.makedirs(path)
     except os.error, e:
         if e.errno != errno.EEXIST:
             raise
diff --git a/daemon/src/Win32Chrono.py b/daemon/src/Win32Chrono.py
index df4fb26..92f3c9e 100644
--- a/daemon/src/Win32Chrono.py
+++ b/daemon/src/Win32Chrono.py
@@ -26,12 +26,9 @@
 import gobject
 import os
 
-import gtop
 import pickle
 import datetime
 
-import dbus
-
 (
 SESSION_APPID,
 WEB_APPID,
diff --git a/daemon/src/Win32SessionFiltering.py b/daemon/src/Win32SessionFiltering.py
index 3bdfecf..b36eef6 100644
--- a/daemon/src/Win32SessionFiltering.py
+++ b/daemon/src/Win32SessionFiltering.py
@@ -46,12 +46,13 @@ class Win32SessionFiltering(gobject.GObject) :
 #             os.system("mkdir -p /var/lib/nanny/desktop_blocks_pids")
         
 #         self.__update_blocks_cb(self.quarterback, self.quarterback.blocks)
-        print "Start Linux Session ConsoleKit Filtering"
+        print "Start Win32 Session Filtering"
 
     def stop(self):
-        print "Stop Linux Session ConsoleKit Filtering"
+        print "Stop Win32 Session Filtering"
 
     def __update_blocks_cb(self, quarterback, blocks):
+        pass
 #         for user_id in blocks.keys() :
 #             if not blocks[user_id].has_key(0) :
 #                 continue
@@ -78,6 +79,7 @@ class Win32SessionFiltering(gobject.GObject) :
 
 
     def __update_cb(self, quarterback, block_status, user_id, app_id, next_change, available_time):
+        pass
 #         if app_id != 0 :
 #             return
 
diff --git a/daemon/src/Win32UsersManager.py b/daemon/src/Win32UsersManager.py
index eb26356..c1fd593 100644
--- a/daemon/src/Win32UsersManager.py
+++ b/daemon/src/Win32UsersManager.py
@@ -43,7 +43,7 @@ class Win32UsersManager:
         if qry.count > 0:
             for result in qry:
                 uid = str(result.SID).split("-")[-1]
-                users.append(uid, unicode(result.Name), unicode(result.FullName))
+                users.append((uid, unicode(result.Name), unicode(result.FullName)))
         self.last_time = time.time()
         return users
 
diff --git a/daemon/src/Win32WebContentFiltering.py b/daemon/src/Win32WebContentFiltering.py
index 31d0d33..017f83e 100644
--- a/daemon/src/Win32WebContentFiltering.py
+++ b/daemon/src/Win32WebContentFiltering.py
@@ -75,6 +75,7 @@ class Win32WebContentFiltering(gobject.GObject) :
             self.__stop_proxy(self.quarterback, uid)
 
     def __start_proxy(self, quarterback, uid):
+        pass
 #         if not self.services.has_key(uid) :
 #             root = ProxyService(uid, quarterback.filter_manager)
 #             sc = service.IServiceCollection(self.app)
@@ -92,6 +93,7 @@ class Win32WebContentFiltering(gobject.GObject) :
 #                 return
         
     def __stop_proxy(self, quarterback, uid):
+        pass
 #         if not self.services.has_key(uid) :
 #             return True
 #         else:
diff --git a/daemon/src/__init__.py b/daemon/src/__init__.py
index 7b98044..5833ed1 100644
--- a/daemon/src/__init__.py
+++ b/daemon/src/__init__.py
@@ -23,7 +23,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 # USA
 
-import 
+import os
+ 
 if os.name == "posix" :
     from LinuxUsersManager import LinuxUsersManager as UsersManager
 elif os.name == "nt" :



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