diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2013-09-13 09:00:13 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2013-09-13 09:00:13 (GMT) |
commit | ca90fccc05475bd63d3532bddba4f482b4e00451 (patch) | |
tree | 91e85467a48564e47fd3bfe74cc5a475eb2e09da | |
parent | 24c9adc6cb3b08462de971323c13e8af4c7ef172 (diff) |
Return only packages while listing /packages API route
-rw-r--r-- | sugar_network/node/routes.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sugar_network/node/routes.py b/sugar_network/node/routes.py index 680c934..4b8b993 100644 --- a/sugar_network/node/routes.py +++ b/sugar_network/node/routes.py @@ -112,6 +112,7 @@ class NodeRoutes(model.VolumeRoutes, model.FrontRoutes): @fallbackroute('GET', ['packages']) def route_packages(self, request, response): enforce(node.files_root.value, http.BadRequest, 'Disabled') + if request.path and request.path[-1] == 'updates': root = join(node.files_root.value, *request.path[:-1]) enforce(isdir(root), http.NotFound, 'Directory was not found') @@ -129,14 +130,20 @@ class NodeRoutes(model.VolumeRoutes, model.FrontRoutes): if last_modified: response.last_modified = last_modified return result - else: - path = join(node.files_root.value, *request.path) - enforce(exists(path), http.NotFound, 'File was not found') - if isdir(path): - response.content_type = 'application/json' - return os.listdir(path) - else: - return toolkit.iter_file(path) + + path = join(node.files_root.value, *request.path) + enforce(exists(path), http.NotFound, 'File was not found') + if not isdir(path): + return toolkit.iter_file(path) + + result = [] + for filename in os.listdir(path): + if filename.endswith('.rpm') or filename.endswith('.deb'): + continue + result.append(filename) + + response.content_type = 'application/json' + return result @route('POST', ['implementation'], cmd='submit', arguments={'initial': False}, |