Changeset 3807
- Timestamp:
- 8 Dec 2008, 16:12:01 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTool.py
r3806 r3807 1229 1229 def removePictureFolder(self,student_id): 1230 1230 """remove picture_folder by renaming it""" 1231 path = 'images' 1232 picture_path = os.path.join(i_home,path,student_id) 1233 if not os.path.exists(picture_path): 1231 picture_path = getImagesDir(student_id) 1232 dest_path = os.path.join("%s" % images_base,'removed',student_id) 1233 dest_path = dest_path + "_removed" 1234 if os.path.exists(dest_path) or not os.path.exists(picture_path): 1234 1235 return False 1235 os.rename(picture_path, picture_path + "_removed")1236 os.rename(picture_path,dest_path) 1236 1237 return True 1237 1238 ###) … … 1240 1241 def restorePictureFolder(self,student_id): 1241 1242 """restore picture_folder by renaming it""" 1242 path = 'images' 1243 picture_path = os.path.join(i_home,path,student_id) 1244 if not os.path.exists(picture_path + "_removed"): 1245 return False 1243 picture_path = getImagesDir(student_id) 1244 orig_path = os.path.join("%s" % images_base,'removed',student_id) 1245 orig_path = orig_path + "_removed" 1246 if os.path.exists(picture_path) or not os.path.exists(orig_path): 1247 return False 1246 1248 os.rename(picture_path + "_removed",picture_path) 1247 1249 return True … … 1264 1266 1265 1267 1266 security.declareProtected(ModifyPortalContent,' findUnusedImageFolders') ###(1267 def findUnusedImageFolders(self):1268 security.declareProtected(ModifyPortalContent,'removeUnusedImageFolders') ###( 1269 def removeUnusedImageFolders(self): 1268 1270 """check if an unused image folders exists in the filesystem""" 1269 1271 mtool = self.portal_membership 1272 member = mtool.getAuthenticatedMember() 1273 member_id = str(member) 1274 logger = logging.getLogger('WAeUPTool.removeUnusedImageFolders') 1270 1275 abc = os.listdir(images_base) 1271 1276 ifolders = [] … … 1274 1279 ifolders.extend(os.listdir(picture_path)) 1275 1280 unused_ids = [] 1276 used_ids = []1277 1281 for id in ifolders: 1278 1282 res = self.students_catalog(id=id) 1279 1283 if not res: 1280 1284 unused_ids.append(id) 1281 else: 1282 used_ids.append(id) 1283 return unused_ids 1285 #import pdb;pdb.set_trace() 1286 if not id.endswith('removed'): 1287 removed = self.waeup_tool.removePictureFolder(id) 1288 if removed: 1289 logger.info('%s: image folder %s successfully removed' % (member_id,id)) 1290 else: 1291 logger.info('%s: image folder %s could not be removed' % (member_id,id)) 1292 return 1284 1293 1285 1294 ###)
Note: See TracChangeset for help on using the changeset viewer.