From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B75191381F3 for ; Wed, 5 Dec 2012 23:56:22 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C305F21C00C; Wed, 5 Dec 2012 23:56:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2BB0421C00C for ; Wed, 5 Dec 2012 23:56:14 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0AE9C33D8E8 for ; Wed, 5 Dec 2012 23:56:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 9C4D2E5436 for ; Wed, 5 Dec 2012 23:56:11 +0000 (UTC) From: "Magnus Granberg" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Magnus Granberg" Message-ID: <1354751751.85cb8ba66d5e4589f8197fb5cff9f235b39a8a5d.zorry@gentoo> Subject: [gentoo-commits] dev/zorry:master commit in: gobs/bin/, gobs/pym/ X-VCS-Repository: dev/zorry X-VCS-Files: gobs/bin/gobs_guest_jobs gobs/pym/build_queru.py gobs/pym/pgsql_querys.py X-VCS-Directories: gobs/bin/ gobs/pym/ X-VCS-Committer: zorry X-VCS-Committer-Name: Magnus Granberg X-VCS-Revision: 85cb8ba66d5e4589f8197fb5cff9f235b39a8a5d X-VCS-Branch: master Date: Wed, 5 Dec 2012 23:56:11 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d3192e0a-9c11-47d6-92cb-c4a1c4ff6538 X-Archives-Hash: 41dc748f45fa0a4abfab00355ef26d82 commit: 85cb8ba66d5e4589f8197fb5cff9f235b39a8a5d Author: Magnus Granberg gentoo org> AuthorDate: Wed Dec 5 23:55:51 2012 +0000 Commit: Magnus Granberg gentoo org> CommitDate: Wed Dec 5 23:55:51 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=85cb8ba6 fist commit for the guest db change --- gobs/bin/gobs_guest_jobs | 2 +- gobs/pym/build_queru.py | 22 +++++++++++------- gobs/pym/pgsql_querys.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/gobs/bin/gobs_guest_jobs b/gobs/bin/gobs_guest_jobs index c3bd6ec..43d0028 100755 --- a/gobs/bin/gobs_guest_jobs +++ b/gobs/bin/gobs_guest_jobs @@ -10,7 +10,7 @@ from gobs.ConnectionManager import connectionManager CM=connectionManager(gobs_settings_dict) #selectively import the pgsql/mysql querys if CM.getName()=='pgsql': - from gobs.pgsql import * + from gobs.pgsql_querys import * from gobs.check_setup import check_configure_guest from gobs.build_queru import queruaction diff --git a/gobs/pym/build_queru.py b/gobs/pym/build_queru.py index d74208c..498a6d7 100644 --- a/gobs/pym/build_queru.py +++ b/gobs/pym/build_queru.py @@ -8,7 +8,7 @@ from gobs.ConnectionManager import connectionManager CM=connectionManager(gobs_settings_dict) #selectively import the pgsql/mysql querys if CM.getName()=='pgsql': - from gobs.pgsql import * + from gobs.pgsql_querys import * import portage import os @@ -67,7 +67,7 @@ class queruaction(object): print('fail_querue_dict', fail_querue_dict) if fail_querue_dict is None: fail_querue_dict = {} - fail_querue_dict['querue_id'] = build_dict['queue_id'] + fail_querue_dict['build_job_id'] = build_dict['build_job_id'] fail_querue_dict['fail_type'] = build_dict['type_fail'] fail_querue_dict['fail_times'] = 1 print('fail_querue_dict', fail_querue_dict) @@ -75,7 +75,7 @@ class queruaction(object): else: if fail_querue_dict['fail_times'][0] < 6: fail_querue_dict['fail_times'] = fail_querue_dict['fail_times'][0] + 1 - fail_querue_dict['querue_id'] = build_dict['queue_id'] + fail_querue_dict['build_job_id'] = build_dict['build_job_id'] fail_querue_dict['fail_type'] = build_dict['type_fail'] update_fail_times(conn, fail_querue_dict) CM.putConnection(conn) @@ -109,7 +109,7 @@ class queruaction(object): os.chmod(settings.get("PORTAGE_LOG_FILE"), 0o224) else: build_log_dict['logfilename'] = "" - move_queru_buildlog(conn, build_dict['queue_id'], build_error, summary_error, build_log_dict) + move_queru_buildlog(conn, build_dict['build_job_id'], build_error, summary_error, build_log_dict) CM.putConnection(conn) def action_build(self, settings, trees, mtimedb, myopts, myaction, myfiles, spinner, build_dict): @@ -626,11 +626,15 @@ class queruaction(object): def make_build_list(self, build_dict, settings, portdb): conn=CM.getConnection() - cpv = build_dict['category']+'/'+build_dict['package']+'-'+build_dict['ebuild_version'] - pkgdir = os.path.join(settings['PORTDIR'], build_dict['category'] + "/" + build_dict['package']) + package_id = build_dict['package_id'] + cp, repo = get_cp_repo_from_package_id(conn, package_id) + element = cp.split('/') + package = element[1] + cpv = cp + "-" + build_dict['ebuild_version'] + pkgdir = self._myportdb.getRepositoryPath(repo) + "/" + cp init_manifest = gobs_manifest(settings, pkgdir) try: - ebuild_version_checksum_tree = portage.checksum.sha256hash(pkgdir+ "/" + build_dict['package'] + "-" + build_dict['ebuild_version'] + ".ebuild")[0] + ebuild_version_checksum_tree = portage.checksum.sha256hash(pkgdir + "/" + package + "-" + build_dict['ebuild_version'] + ".ebuild")[0] except: ebuild_version_checksum_tree = None if ebuild_version_checksum_tree == build_dict['checksum']: @@ -704,8 +708,8 @@ class queruaction(object): pass build_dict2 = {} build_dict2 = get_packages_to_build(conn, self._config_profile) - if build_dict['queue_id'] == build_dict2['queue_id']: - log_msg = "qurery %s was not removed" % (build_dict['queue_id'],) + if build_dict['build_job_id'] == build_dict2['build_job_id']: + log_msg = "qurery %s was not removed" % (build_dict['build_job_id'],) add_gobs_logs(conn, log_msg, "info", self._config_profile) print("qurery was not removed") build_dict['type_fail'] = "Querey was not removed" diff --git a/gobs/pym/pgsql_querys.py b/gobs/pym/pgsql_querys.py index 3c0813d..6f75e53 100644 --- a/gobs/pym/pgsql_querys.py +++ b/gobs/pym/pgsql_querys.py @@ -314,3 +314,57 @@ def del_old_build_jobs(connection, queue_id): cursor.execute(sqlQ2, (build_job_id,)) cursor.execute(sqlQ3, (build_job_id,)) connection.commit() + +def get_packages_to_build(connection, config): + cursor =connection.cursor() + sqlQ1 = "SELECT build_job_id.build_jobs, ebuild_id.build_jobs, package_id.ebuilds FROM build_jobs, ebuilds WHERE config_id.build_jobs = (SELECT config_id FROM configs WHERE config = %s) + AND extract(epoch from (NOW()) - timestamp.build_jobs) > 7200 AND ebuild_id.build_jobs = ebuild_id.ebuilds + AND ebuilds.active = 'True' ORDER BY LIMIT 1" + sqlQ2 = 'SELECT version, checksum FROM ebuilds WHERE ebuild_id = %s' + sqlQ3 = 'SELECT flag.uses, status.build_jobs_use FROM build_jobs_use, uses WHERE build_job_id.build_jobs_use = %s use_id.build_jobs_use = use_id.uses' + cursor.execute(sqlQ1, (config,)) + build_dict={} + entries = cursor.fetchone() + if entries is None: + return None + build_dict['build_job_id'] = entries[0] + build_dict['ebuild_id']= entries[1] + build_dict['package_id'] = entries[2] + cursor.execute(sqlQ2, (entries[1],)) + entries = cursor.fetchone() + build_dict['ebuild_version'] = entries[0] + build_dict['checksum']=entries[1] + #add a enabled and disabled list to the objects in the item list + cursor.execute(sqlQ3, (build_dict['build_job_id'],)) + uses={} + for row in cursor.fetchall(): + uses[ row[0] ] = row[1] + build_dict['build_useflags']=uses + return build_dict + +def update_fail_times(connection, fail_querue_dict): + cursor = connection.cursor() + sqlQ1 = 'UPDATE build_jobs_retest SET fail_times = %s WHERE build_job_id = %s AND fail_type = %s' + sqlQ2 = 'UPDATE build_jobs SET time_stamp = NOW() WHERE build_job_id = %s' + cursor.execute(sqlQ1, (fail_querue_dict['fail_times'], fail_querue_dict['build_job_id'], fail_querue_dict['fail_type'],)) + cursor.execute(sqlQ2, (fail_querue_dict['build_job_id'],)) + connection.commit() + +def get_fail_querue_dict(connection, build_dict): + cursor = connection.cursor() + fail_querue_dict = {} + sqlQ = 'SELECT fail_times FROM build_jobs_retest WHERE build_job_id = %s AND fail_type = %s' + cursor.execute(sqlQ, (build_dict['build_job_id'], build_dict['type_fail'],)) + entries = cursor.fetchone() + if entries is None: + return None + fail_querue_dict['fail_times'] = entries + return fail_querue_dict + +def add_fail_querue_dict(connection, fail_querue_dict): + cursor = connection.cursor() + sqlQ1 = 'INSERT INTO build_jobs_retest (build_job_id, fail_type, fail_times) VALUES ( %s, %s, %s)' + sqlQ2 = 'UPDATE build_jobs SET time_stamp = NOW() WHERE build_job_id = %s' + cursor.execute(sqlQ1, (fail_querue_dict['build_job_id'],fail_querue_dict['fail_type'], fail_querue_dict['fail_times'])) + cursor.execute(sqlQ2, (fail_querue_dict['build_job_id'],)) + connection.commit() \ No newline at end of file