From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1SOVLd-0001Mm-NR for garchives@archives.gentoo.org; Sun, 29 Apr 2012 14:43:37 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 30C7BE0539; Sun, 29 Apr 2012 14:43:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E4846E0539 for ; Sun, 29 Apr 2012 14:43:28 +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 30B0A1B4001 for ; Sun, 29 Apr 2012 14:43:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id EA83CE5403 for ; Sun, 29 Apr 2012 14:43:25 +0000 (UTC) From: "Magnus Granberg" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Magnus Granberg" Message-ID: <1335710569.a2502fc4a74dfd0aced82648ed3a7a4593a2a476.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_host_jobs gobs/bin/gobs_host_jobs~ gobs/bin/gobs_updatedb gobs/pym/pgsql.py gobs/pym/updatedb.py X-VCS-Directories: gobs/bin/ gobs/pym/ X-VCS-Committer: zorry X-VCS-Committer-Name: Magnus Granberg X-VCS-Revision: a2502fc4a74dfd0aced82648ed3a7a4593a2a476 X-VCS-Branch: master Date: Sun, 29 Apr 2012 14:43:25 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 9d776057-5f33-4107-8934-415cfeb46aca X-Archives-Hash: 5cb0d8ef2888a6f27acc6d8658eecb69 commit: a2502fc4a74dfd0aced82648ed3a7a4593a2a476 Author: Magnus Granberg gentoo org> AuthorDate: Sun Apr 29 14:42:49 2012 +0000 Commit: Magnus Granberg gentoo org> CommitDate: Sun Apr 29 14:42:49 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Ddev/zorry.git;a=3D= commit;h=3Da2502fc4 adding updatedb to job host deamon --- gobs/bin/gobs_host_jobs | 28 +++++++++++++++++---= ----- gobs/bin/{gobs_host_jobs =3D> gobs_host_jobs~} | 28 +++++++++++++++++-= ------- gobs/pym/pgsql.py | 6 ++-- gobs/{bin/gobs_updatedb =3D> pym/updatedb.py} | 11 ++------- 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/gobs/bin/gobs_host_jobs b/gobs/bin/gobs_host_jobs index e6e5ead..87e856e 100755 --- a/gobs/bin/gobs_host_jobs +++ b/gobs/bin/gobs_host_jobs @@ -6,6 +6,8 @@ from __future__ import print_function =20 from gobs.init_setup_profile import setup_profile_main from gobs.readconf import get_conf_settings +from gobs.updatedb import update_db_main + reader =3D get_conf_settings() gobs_settings_dict=3Dreader.read_gobs_settings_all() =20 @@ -15,31 +17,39 @@ CM=3DconnectionManager(gobs_settings_dict) #selectively import the pgsql/mysql querys if CM.getName()=3D=3D'pgsql': from gobs.pgsql import * -# import logging +import logging =20 def main(): # Main config_profile =3D gobs_settings_dict['gobs_config'] # Logging - #logging.basicConfig(filename=3Dgobs_settings_dict['gobs_logfile'], \ - # format=3D'%(levelname)s: %(asctime)s %(message)s', level=3Dlogging.IN= FO) - conn =3D CM.getConnection() - CM.putConnection(conn) + logging.basicConfig(filename=3Dgobs_settings_dict['gobs_logfile'], \ + format=3D'%(levelname)s: %(asctime)s %(message)s', level=3Dlogging.INF= O) repeat =3D True + logging.info("Job deamon started.") while repeat: conn =3D CM.getConnection() job =3D check_job_list(conn, config_profile) - print("job jobid:" + job) + =09 if job is None: time.sleep(60) CM.putConnection(conn) continue else: - update_job_list("Runing", job[1]) + logging.info("Job: %s Type: %s Config: %s", job[1], job[0], config_pr= ofile) + if job[0] =3D=3D "updatedb": + update_job_list(conn, "Runing", job[1]) + logging.info("Job %s is runing. Config: %s", job[0], config_profile) + result =3D update_db_main() + if result is True + update_job_list(conn, "Done", job[1]) + logging.info("Job %s is done. Config: %s", job[0], config_profile) + else: + update_job_list(conn, "Fail", job[1]) + logging.info("Job %s did fail. Config: %s", job[0], config_profile) repeat =3D False CM.putConnection(conn) time.sleep(60) - connectionManager.closeAllConnections() -=09 + if __name__ =3D=3D "__main__": main() \ No newline at end of file diff --git a/gobs/bin/gobs_host_jobs b/gobs/bin/gobs_host_jobs~ similarity index 54% copy from gobs/bin/gobs_host_jobs copy to gobs/bin/gobs_host_jobs~ index e6e5ead..87e856e 100755 --- a/gobs/bin/gobs_host_jobs +++ b/gobs/bin/gobs_host_jobs~ @@ -6,6 +6,8 @@ from __future__ import print_function =20 from gobs.init_setup_profile import setup_profile_main from gobs.readconf import get_conf_settings +from gobs.updatedb import update_db_main + reader =3D get_conf_settings() gobs_settings_dict=3Dreader.read_gobs_settings_all() =20 @@ -15,31 +17,39 @@ CM=3DconnectionManager(gobs_settings_dict) #selectively import the pgsql/mysql querys if CM.getName()=3D=3D'pgsql': from gobs.pgsql import * -# import logging +import logging =20 def main(): # Main config_profile =3D gobs_settings_dict['gobs_config'] # Logging - #logging.basicConfig(filename=3Dgobs_settings_dict['gobs_logfile'], \ - # format=3D'%(levelname)s: %(asctime)s %(message)s', level=3Dlogging.IN= FO) - conn =3D CM.getConnection() - CM.putConnection(conn) + logging.basicConfig(filename=3Dgobs_settings_dict['gobs_logfile'], \ + format=3D'%(levelname)s: %(asctime)s %(message)s', level=3Dlogging.INF= O) repeat =3D True + logging.info("Job deamon started.") while repeat: conn =3D CM.getConnection() job =3D check_job_list(conn, config_profile) - print("job jobid:" + job) + =09 if job is None: time.sleep(60) CM.putConnection(conn) continue else: - update_job_list("Runing", job[1]) + logging.info("Job: %s Type: %s Config: %s", job[1], job[0], config_pr= ofile) + if job[0] =3D=3D "updatedb": + update_job_list(conn, "Runing", job[1]) + logging.info("Job %s is runing. Config: %s", job[0], config_profile) + result =3D update_db_main() + if result is True + update_job_list(conn, "Done", job[1]) + logging.info("Job %s is done. Config: %s", job[0], config_profile) + else: + update_job_list(conn, "Fail", job[1]) + logging.info("Job %s did fail. Config: %s", job[0], config_profile) repeat =3D False CM.putConnection(conn) time.sleep(60) - connectionManager.closeAllConnections() -=09 + if __name__ =3D=3D "__main__": main() \ No newline at end of file diff --git a/gobs/pym/pgsql.py b/gobs/pym/pgsql.py index 5ebe500..64f1b46 100644 --- a/gobs/pym/pgsql.py +++ b/gobs/pym/pgsql.py @@ -639,7 +639,7 @@ def make_conf_error(connection,config_profile): =20 def check_job_list(connection, config_profile): cursor =3D connection.cursor() - sqlQ1 =3D 'SELECT idnr FROM configs WHERE id =3D %s' + sqlQ1 =3D 'SELECT id_nr FROM configs WHERE id =3D %s' sqlQ2 =3D "SELECT job, jobnr FROM jobs_list WHERE status =3D 'Waiting' = AND config_id =3D %s" cursor.execute(sqlQ1, (config_profile,)) config_nr =3D cursor.fetchone() @@ -649,8 +649,8 @@ def check_job_list(connection, config_profile): return None return job =09 -def update_job_list(status, jobid): +def update_job_list(connection, status, jobid): cursor =3D connection.cursor() - sqlQ =3D 'UPDATE jobs_list SET ststus =3D %s WHERE jobid =3D %s' + sqlQ =3D 'UPDATE jobs_list SET status =3D %s WHERE jobnr =3D %s' cursor.execute(sqlQ, (status, jobid,)) connection.commit() diff --git a/gobs/bin/gobs_updatedb b/gobs/pym/updatedb.py similarity index 95% rename from gobs/bin/gobs_updatedb rename to gobs/pym/updatedb.py index d7bfbee..738179f 100755 --- a/gobs/bin/gobs_updatedb +++ b/gobs/pym/updatedb.py @@ -1,10 +1,9 @@ -#!/usr/bin/python # Copyright 2006-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 =20 """ This code will update the sql backend with needed info for the Frontend and the Guest deamon. """ - +from __future__ import print_function import sys import os import multiprocessing @@ -110,11 +109,9 @@ def update_cpv_db(mysettings): pool.join()=20 logging.info("Checking categories, package and ebuilds done") =20 -def main(): +def update_db_main(): # Main # Logging - logging.basicConfig(filename=3Dgobs_settings_dict['gobs_logfile'], \ - format=3D'%(levelname)s: %(asctime)s %(message)s', level=3Dlogging.INF= O) logging.info("Update db started.") # Sync portage and profile/settings git_pull @@ -127,6 +124,4 @@ def main(): update_cpv_db(mysettings) CM.closeAllConnections() logging.info("Update db ... Done.") -=09 -if __name__ =3D=3D "__main__": - main() \ No newline at end of file + return True \ No newline at end of file