From ca90fccc05475bd63d3532bddba4f482b4e00451 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Fri, 13 Sep 2013 09:00:13 +0000 Subject: Return only packages while listing /packages API route --- 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}, -- cgit v0.9.1