You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by sk...@apache.org on 2013/08/06 01:04:25 UTC
svn commit: r1510797 -
/incubator/climate/trunk/rcmet/src/main/python/rcmes/services/directory_helpers.py
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}