changeset 20:89978106f0bb

commented out dir session cleanup code
author gyorgyf
date Tue, 19 Mar 2013 16:32:14 +0000
parents 75e67af92ef8
children a647bd7dd38d
files DirectorySession.py
diffstat 1 files changed, 23 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/DirectorySession.py	Tue Mar 19 13:57:27 2013 +0000
+++ b/DirectorySession.py	Tue Mar 19 16:32:14 2013 +0000
@@ -25,13 +25,6 @@
 	instanceList = []
 	
 	def __init__(self, id=None, **kwargs):
-		# for i in self.instanceList : 
-		# 	print 'previous-sessions: ', i.id
-		# 	if (i.id == id) :
-		# 		print 'got instance already!'
-		# self.instanceList.append(self)
-		# print 'instance initialised:' + str(len(self.instanceList))
-		# kwargs['SESSIONS_PATH'] = os.path.abspath(kwargs['SESSIONS_PATH'])
 
 		if not id in self.cache: 
 			new_session_signal = True
@@ -200,37 +193,37 @@
 		"""Clean up expired sessions."""
 		now = datetime.datetime.now()
 		log_msg = "Session x.xx: mxxx. Cherrypy::DirectorySession: Cleaning up session data at: %s Length of cache = %i " %(str(now), len(self.cache))
-		print '\nCeaning up session data at %s: \n===========================' % now
-		print 'Length of cache = ', len(self.cache)
-		print 'cache members: ', self.cache.keys()
+		# print '\nCeaning up session data at %s: \n===========================' % now
+		# print 'Length of cache = ', len(self.cache)
+		# print 'cache members: ', self.cache.keys()
 		cherrypy.log(log_msg)
 		
 		#clean up temp if server not in use
-		temp_path='/Users/Shared/george/sawa/sonic-annotator-webapp/static/temp/'
-		if len(self.cache.keys()) == 0 and os.path.exists(temp_path):
-			try :
-				for fname in os.listdir(temp_path):
-					os.remove(os.path.join(temp_path,fname))
-				print "Note: Cleaned temp directory."
-			except:
-				print "Warning: could not clear temp directory."
-				pass
+		# temp_path='/Users/Shared/george/sawa/sonic-annotator-webapp/static/temp/'
+		# if len(self.cache.keys()) == 0 and os.path.exists(temp_path):
+		# 	try :
+		# 		for fname in os.listdir(temp_path):
+		# 			os.remove(os.path.join(temp_path,fname))
+		# 		print "Note: Cleaned temp directory."
+		# 	except:
+		# 		print "Warning: could not clear temp directory."
+		# 		pass
 		
 		for id, (data, expiration_time) in self.cache.items():
-			print 'Id: ', id
-			print 'expiration time: ', expiration_time
-			print 'Length of data: ', len(data)
-			print 'data members: ', data.keys()
-			print 'SESSIONS_PATH: ', self.SESSIONS_PATH
+			# print 'Id: ', id
+			# print 'expiration time: ', expiration_time
+			# print 'Length of data: ', len(data)
+			# print 'data members: ', data.keys()
+			# print 'SESSIONS_PATH: ', self.SESSIONS_PATH
 
 			if expiration_time < now:
 
-				path = os.path.join(self.SESSIONS_PATH,str(id))
-				if os.path.exists(path) :
-					for fname in os.listdir(path):
-						os.remove(os.path.join(path,fname))
-					# os.removedirs(path) -> removes sessions too
-					os.rmdir(path)					
+				# path = os.path.join(self.SESSIONS_PATH,str(id))
+				# if os.path.exists(path) :
+				# 	for fname in os.listdir(path):
+				# 		os.remove(os.path.join(path,fname))
+				# 	# os.removedirs(path) -> removes sessions too
+				# 	os.rmdir(path)					
 				try:
 					del self.cache[id]
 				except KeyError: