From fa4ec80cbd367f3a9923dbd1a8b3387f21deb153 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Wed, 14 Jan 2015 19:56:58 +0100 Subject: reproducible: add a pkg_has_buildinfo common function, to avoid code duplication --- bin/reproducible_common.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'bin/reproducible_common.py') diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py index cc0c396a..887a2720 100755 --- a/bin/reproducible_common.py +++ b/bin/reproducible_common.py @@ -223,8 +223,11 @@ def join_status_icon(status, package=None, version=None): 'not_for_us': 'weather-few-clouds-night.png', 'blacklisted': 'error.png'} if status == 'unreproducible': - if os.access(BUILDINFO_PATH + '/' + str(package) + '_' + \ - strip_epoch(str(version)) + '_amd64.buildinfo', os.R_OK): + if not package: + log.error('Could not determinate the real state of package None. ' + + 'Returning a generic "FTBR"') + status = 'FTBR' + elif pkg_has_buildinfo(package, version): status = 'FTBR_with_buildinfo' else: status = 'FTBR' @@ -252,6 +255,20 @@ def strip_epoch(version): except IndexError: return version +def pkg_has_buildinfo(package, version=False): + """ + if there is no version specified it will use the version listed in + reproducible.db + """ + if not version: + query = 'SELECT version FROM source_packages WHERE name="%s"' % package + version = str(query_db(query)[0][0]) + buildinfo = BUILDINFO_PATH + '/' + package + '_' + \ + strip_epoch(version) + '_amd64.buildinfo' + if os.access(buildinfo, os.R_OK): + return True + else: + return False # do the db querying conn = init_conn() -- cgit v1.2.3-70-g09d2