climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skhud...@apache.org
Subject svn commit: r1499511 - /incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py
Date Wed, 03 Jul 2013 18:37:39 GMT
Author: skhudiky
Date: Wed Jul  3 18:37:38 2013
New Revision: 1499511

URL: http://svn.apache.org/r1499511
Log:
CLIMATE-173: Add service to return list of figures in work directory

Modified:
    incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py

Modified: incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py
URL: http://svn.apache.org/viewvc/incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py?rev=1499511&r1=1499510&r2=1499511&view=diff
==============================================================================
--- incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py (original)
+++ incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py Wed
Jul  3 18:37:38 2013
@@ -48,6 +48,31 @@ def getDirectoryInfo(dirPath):
     else:
         return returnJSON
 
+WORK_DIR = "/tmp/rcmet"
+
+@route('/getResultDirInfo')
+def getResultDirInfo():
+    dirPath = WORK_DIR
+    dirPath = dirPath.replace('/../', '/')
+    dirPath = dirPath.replace('/./', '/')
+
+    if os.path.isdir(dirPath):
+        listing = os.listdir(dirPath)
+        listingNoHidden = [f for f in listing if f[0] != '.']
+        joinedPaths = [os.path.join(dirPath, f) for f in listingNoHidden]
+        joinedPaths = [f + "/" if os.path.isdir(f) else f for f in joinedPaths]
+        finalPaths = [p.replace(WORK_DIR, '') for p in joinedPaths]
+        sorted(finalPaths, key=lambda s: s.lower())
+        returnJSON = finalPaths
+    else:
+        returnJSON = []
+
+    returnJSON = json.dumps(returnJSON)
+    if request.query.callback:
+        return "%s(%s)" % (request.query.callback, returnJSON)
+    else:
+        return returnJSON
+
 @route('/getPathLeader/')
 def getPathLeader():
     returnJSON = {"leader": PATH_LEADER}



Mime
View raw message