climate-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skhud...@apache.org
Subject svn commit: r1510797 - /incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py
Date Mon, 05 Aug 2013 23:04:25 GMT
Author: skhudiky
Date: Mon Aug  5 23:04:25 2013
New Revision: 1510797

URL: http://svn.apache.org/r1510797
Log:
CLIMATE-245: Add service to return all results for a specified 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=1510797&r1=1510796&r2=1510797&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 Mon
Aug  5 23:04:25 2013
@@ -74,6 +74,29 @@ def getResultDirInfo():
     else:
         return returnJSON
 
+@route('/getResults/<dirPath:path>')
+def getResults(dirPath):
+    dirPath = WORK_DIR + dirPath
+    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]
+        onlyFilesNoDirs = [f for f in joinedPaths if os.path.isfile(f)]
+        finalPaths = [p.replace(WORK_DIR, '') for p in onlyFilesNoDirs]
+        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