# -*- coding: utf-8 -*-
# $Id$
"""
Test Manager - Builds Blacklist.
"""
__copyright__ = \
"""
Copyright (C) 2012-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Validation Kit imports.
"""
Build Blacklist Data.
"""
'tsEffective',
'tsExpire',
'uidAuthor',
'asTypes',
'asOsArches' ];
#
# Initialize with defaults.
# See the database for explanations of each of these fields.
#
self.idBlacklisting = None
self.tsEffective = None
self.idFailureReason = None
self.asOsArches = None
self.iFirstRevision = None
self.iLastRevision = None
"""
Re-initializes the data with a row from a SELECT * FROM BuildBlacklist.
Returns self. Raises exception if the row is None or otherwise invalid.
"""
if aoRow is None:
raise TMExceptionBase('Build Blacklist item not found.')
return self;
"""
Initialize the object from the database.
"""
'SELECT *\n'
'FROM BuildBlacklist\n'
'WHERE idBlacklisting = %s\n'
if aoRow is None:
raise TMExceptionBase('idBlacklisting=%s not found (tsNow=%s sPeriodBack=%s)'
"""
Build Back List logic.
"""
"""
Fetches Build Blacklist records.
Returns an array (list) of BuildBlacklistData items, empty list if none.
Raises exception on error.
"""
if tsNow is None:
'FROM BuildBlacklist\n'
'WHERE tsExpire = \'infinity\'::TIMESTAMP\n'
'ORDER BY idBlacklisting DESC\n'
'LIMIT %s OFFSET %s\n'
else:
'FROM BuildBlacklist\n'
'WHERE tsExpire > %s\n'
' AND tsEffective <= %s\n'
'ORDER BY idBlacklisting DESC\n'
'LIMIT %s OFFSET %s\n'
aoRows = []
return aoRows
"""
Adds a blacklisting to the database.
"""
' uidAuthor,\n'
' idFailureReason,\n'
' sProduct,\n'
' sBranch,\n'
' asTypes,\n'
' asOsArches,\n'
' iFirstRevision,\n'
' iLastRevision)\n'
'VALUES (%s, %s, %s, %s, %s, %s, %s, %s)'
, ( uidAuthor,
oData.iLastRevision,) );
return True
"""
Modifies a blacklisting.
"""
#
# Validate inputs and read in the old(/current) data.
#
#
# Update the data that needs updating.
#
return True;
"""
Deletes a test group.
"""
_ = fCascade; # Not applicable.
'SET tsExpire = CURRENT_TIMESTAMP\n'
'WHERE idBlacklisting = %s\n'
' AND tsExpire = \'infinity\'::TIMESTAMP\n'
, (idBlacklisting,));
return True;
#
# Helpers.
#
"""
Historizes the current entry for the given backlisting.
"""
if tsExpire is None:
'SET tsExpire = %s\n'
'WHERE idBlacklisting = %s\n'
' AND tsExpire = \'infinity\'::TIMESTAMP\n'
, ( tsExpire, idBlacklisting, ));
return True;
"""
Re-adds the BuildBlacklist entry. Used by editEntry and removeEntry.
"""
if tsEffective is None:
' uidAuthor,\n'
' tsEffective,\n'
' idBlacklisting,\n'
' idFailureReason,\n'
' sProduct,\n'
' sBranch,\n'
' asTypes,\n'
' asOsArches,\n'
' iFirstRevision,\n'
' iLastRevision)\n'
'VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n'
, ( uidAuthor,
oData.iLastRevision,) );
return True;