[snapshot/master] Implement /mr/binary/<binpkg>/<binversion>/binfiles
---
API | 17 +++++++++++++++++
web/app/snapshot/config/routing.py | 3 ++-
web/app/snapshot/controllers/package.py | 17 ++++++++++++++++-
web/app/snapshot/model/snapshotmodel.py | 13 ++++++++++++-
4 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/API b/API
index e5adc00..602b32f 100644
--- a/API
+++ b/API
@@ -136,6 +136,23 @@ summary: find binary package versions and corresponding source names and version
]
}
+URL: /mr/binary/<binpkg>/<binversion>/binfiles
+Options: fileinfo=1 includes fileinfo section
+http status codes: 200 500 404 304
+summary: list all files associated with a binary package
+note: different source packages can build binaries with the same binary package name/version tuple.
+{ '_comment': "yadayadayda",
+ 'binary': "tor",
+ 'binary-version': '0.2.1.22-1',
+ 'result':
+ [ { 'architecture': 'mipsel', hash: '2a3f98cce2f8054621e53d91c7c02d7125ea9c82' },
+ { 'architecture': 'hurd-i386', hash: 'a4e9f6abf9664a44f7c94208a236464a59a68103' },
+ { 'architecture': 'mips', hash: 'a2bfcdb202331e52b0a50cbce02623083328237e' },
+ ...
+ ]
+}
+
+
diff --git a/web/app/snapshot/config/routing.py b/web/app/snapshot/config/routing.py
index 99eb02b..f5c28aa 100644
--- a/web/app/snapshot/config/routing.py
+++ b/web/app/snapshot/config/routing.py
@@ -1,6 +1,6 @@
## snapshot.debian.org - web frontend
#
-# Copyright (c) 2009, 2010 Peter Palfrader
+# Copyright (c) 2009, 2010, 2015 Peter Palfrader
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -65,6 +65,7 @@ def make_map():
map.connect('/mr/package/{source}/{version}/allfiles', controller='package', action='mr_source_version_allfiles')
map.connect('/mr/binary/{binary}/', controller='package', action='mr_binary')
+ map.connect('/mr/binary/{binary}/{binary_version}/binfiles', controller='package', action='mr_binary_version_binfiles')
map.connect('/file/{hash}', controller='archive', action='file')
map.connect('/mr/file/{hash}/info', controller='package', action='mr_fileinfo')
diff --git a/web/app/snapshot/controllers/package.py b/web/app/snapshot/controllers/package.py
index 9dba54f..99b67f8 100644
--- a/web/app/snapshot/controllers/package.py
+++ b/web/app/snapshot/controllers/package.py
@@ -1,6 +1,6 @@
## snapshot.debian.org - web frontend
#
-# Copyright (c) 2009, 2010 Peter Palfrader
+# Copyright (c) 2009, 2010, 2015 Peter Palfrader
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -365,6 +365,21 @@ class PackageController(BaseController):
finally:
self._db_close()
+ @jsonify
+ def mr_binary_version_binfiles(self, binary, binary_version):
+ try:
+ binfiles = app_globals.shm.packages_get_binary_files(self._db(), binary, binary_version)
+ if len(binfiles) == 0: abort(404, 'No such package or no binary files found')
+ binfiles = map(lambda b: dict(b), binfiles)
+ r = { '_comment': "foo",
+ 'binary': binary,
+ 'binary_version': binary_version,
+ 'result': binfiles }
+ if ('fileinfo' in request.params) and (request.params['fileinfo'] == '1'):
+ r['fileinfo'] = self._get_fileinfo_for_mr(map(lambda x: x['hash'], binfiles))
+ return r
+ finally:
+ self._db_close()
@jsonify
def mr_fileinfo(self, hash):
diff --git a/web/app/snapshot/model/snapshotmodel.py b/web/app/snapshot/model/snapshotmodel.py
index aa357f8..09bff3b 100644
--- a/web/app/snapshot/model/snapshotmodel.py
+++ b/web/app/snapshot/model/snapshotmodel.py
@@ -1,6 +1,6 @@
## snapshot.debian.org - web frontend
#
-# Copyright (c) 2009, 2010 Peter Palfrader
+# Copyright (c) 2009, 2010, 2015 Peter Palfrader
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -308,6 +308,17 @@ class SnapshotModel:
{ 'binary': binary} )
return rows
+ def packages_get_binary_files(self, db, binary, binary_version):
+ rows = db.query("""SELECT hash, architecture
+ FROM file_binpkg_mapping
+ JOIN binpkg
+ ON binpkg.binpkg_id=file_binpkg_mapping.binpkg_id
+ WHERE name=%(binary)s AND version=%(binary_version)s""",
+ { 'binary': binary,
+ 'binary_version': binary_version} )
+
+ return rows
+
def packages_get_binary_files_from_id(self, db, binpkg_id):
rows = db.query("""SELECT hash, architecture
FROM file_binpkg_mapping
--
1.7.10.4
Reply to: