def delete(self, args): """Remove a test subject from the database. This will also remove all schedule entries for this subject. Arguments: subject -- Name of the test subject """ checks.chk_arg_count(args, 2) subject, bitness = args subject = checks.chk_subject(subject) bitness = checks.chk_bitness(bitness) self.cursor.execute(''' SELECT subject_id FROM subject WHERE subject_name=? AND is_64bit=?''', (subject, bitness)) subjectid = self.cursor.fetchone() if subjectid == None: raise ValueError('No such test subject.') queue = TapperQueue(subject, bitness) queue.delete() self.cursor.execute(''' DELETE FROM subject_schedule WHERE subject_id=?''', subjectid) self.cursor.execute(''' DELETE FROM completion WHERE subject_id=?''', subjectid) self.cursor.execute(''' DELETE FROM subject WHERE subject_id=?''', subjectid) self.connection.commit()
def __disable(self, subject, bitness): """Disable a test subject Deactivates the Tapper queue for the test subject and disables the test subject in the Temare database. Arguments: subject -- Name of the test subject bitness -- Bitness of the test subject (0 = 32-bit, 1 = 64-bit) """ queue = TapperQueue(subject, bitness) queue.disable() self.cursor.execute(''' UPDATE subject SET is_enabled=0 WHERE subject_name=? AND is_64bit=?''', (subject, bitness)) self.connection.commit()
def __enable(self, subject, bitness, priority): """Enable a test subject Enables the test subject in the temare database and activates the Tapper queue with the given priority. Disables the test subject in the Temare database again if activating the Tapper queue failed for some reason. Arguments: subject -- Name of the test subject bitness -- Bitness of the test subject (0 = 32-bit, 1 = 64-bit) priority -- Bandwidth setting of the Tapper queue (int) """ if subject.startswith('autoinstall'): grubvalues = {} self.cursor.execute(''' SELECT key, value FROM completion LEFT JOIN subject ON completion.subject_id=subject.subject_id WHERE subject_name=? AND is_64bit=?''', (subject, bitness)) for key, value in self.cursor.fetchall(): grubvalues[key] = value checks.chk_grub_template(subject, grubvalues) self.cursor.execute(''' UPDATE subject SET is_enabled=1, subject_prio=? WHERE subject_name=? AND is_64bit=?''', (priority, subject, bitness)) self.connection.commit() queue = TapperQueue(subject, bitness) try: queue.enable(priority) except ValueError, err: self.cursor.execute(''' UPDATE subject SET is_enabled=0 WHERE subject_name=? AND is_64bit=?''', (subject, bitness)) self.connection.commit() raise err