[nanny] Add relative multiplatform paths to TwistedProxy.py



commit ed933d1f5a2b1a1a41348c7746299f4ecfbad7c8
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Wed Sep 15 13:03:41 2010 +0200

    Add relative multiplatform paths to TwistedProxy.py

 daemon/src/proxy/TwistedProxy.py |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/daemon/src/proxy/TwistedProxy.py b/daemon/src/proxy/TwistedProxy.py
index a146da2..256c32d 100644
--- a/daemon/src/proxy/TwistedProxy.py
+++ b/daemon/src/proxy/TwistedProxy.py
@@ -61,12 +61,19 @@ BAD_WEB_TEMPLATE='''
 </body>
 '''
 
-BAD_CONTENT_TMP_DIR="/var/tmp/nanny"
+
+if os.name == "posix" :
+    BAD_CONTENT_TMP_DIR = "/var/tmp/nanny/"
+elif os.name == "nt" :
+    BAD_CONTENT_TMP_DIR = "C:\\WINDOWS\\nanny_data\\tmp"
 
 class BadBoyResponseFilter:
     def __init__(self, client):
         if not os.path.exists(BAD_CONTENT_TMP_DIR) :
-            os.system("mkdir -p %s" % BAD_CONTENT_TMP_DIR)
+            try:
+                os.makedirs(BAD_CONTENT_TMP_DIR)
+            except:
+                pass
         
         self.fd_orig = TemporaryFile(mode='rw+b', dir=BAD_CONTENT_TMP_DIR)
         self.fd_filtered = TemporaryFile(mode='rw+b', dir=BAD_CONTENT_TMP_DIR)



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