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 2E1E41381F3 for ; Sun, 23 Dec 2012 17:09:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9B57921C01B; Sun, 23 Dec 2012 17:09:10 +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 15A9021C01B for ; Sun, 23 Dec 2012 17:09:10 +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 0253133D866 for ; Sun, 23 Dec 2012 17:09:09 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 91A2DE543C for ; Sun, 23 Dec 2012 17:09:07 +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: <1356282528.568ff94daf38bbdfbafb0b296f935a74424e6744.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_cron gobs/pym/cron.py gobs/pym/mysql_querys.py X-VCS-Directories: gobs/bin/ gobs/pym/ X-VCS-Committer: zorry X-VCS-Committer-Name: Magnus Granberg X-VCS-Revision: 568ff94daf38bbdfbafb0b296f935a74424e6744 X-VCS-Branch: master Date: Sun, 23 Dec 2012 17:09:07 +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: 234061dc-e09d-4d7b-adff-fc5fa3142519 X-Archives-Hash: c1893c01760eca10cc8708582fcb16f3 commit: 568ff94daf38bbdfbafb0b296f935a74424e6744 Author: Magnus Granberg gentoo org> AuthorDate: Sun Dec 23 17:08:48 2012 +0000 Commit: Magnus Granberg gentoo org> CommitDate: Sun Dec 23 17:08:48 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=568ff94d We use the Event scheduler in the mysql for the cron stuff --- gobs/bin/gobs_cron | 25 ------------------------- gobs/pym/cron.py | 13 ------------- gobs/pym/mysql_querys.py | 42 ------------------------------------------ 3 files changed, 0 insertions(+), 80 deletions(-) diff --git a/gobs/bin/gobs_cron b/gobs/bin/gobs_cron deleted file mode 100755 index 773700b..0000000 --- a/gobs/bin/gobs_cron +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/python -# Distributed under the terms of the GNU General Public License v2 - -from __future__ import print_function - -from gobs.readconf import get_conf_settings -from gobs.cron import cron_main -from gobs.ConnectionManager import connectionManager -from gobs.mysql_querys import add_gobs_logs, get_config_id - -def main(): - # Main - reader = get_conf_settings() - gobs_settings_dict=reader.read_gobs_settings_all() - config_profile = gobs_settings_dict['gobs_config'] - CM=connectionManager() - conn = CM.newConnection() - config_id = get_config_id(conn, config_profile) - add_gobs_logs(conn, "Cron job started", "info", config_id) - cron_main(conn, config_id) - add_gobs_logs(conn, "Cron job done.", "info", config_id) - conn.close - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/gobs/pym/cron.py b/gobs/pym/cron.py deleted file mode 100644 index 706719f..0000000 --- a/gobs/pym/cron.py +++ /dev/null @@ -1,13 +0,0 @@ -from __future__ import print_function - -from gobs.mysql_querys import get_cron_jobs, get_cron_info, check_jobs, \ - add_new_job, add_gobs_logs - -def cron_main(conn, config_id): - cron_id_list = get_cron_jobs(conn, config_id) - for cron_id in cron_id_list: - job_type_id, run_config_id = get_cron_info(conn, cron_id) - if not check_jobs(conn, job_type_id, config_id, run_config_id): - log_msg = "Job: %s added to job list on %s for %s" % (job_type_id, config_id, run_config_id,) - add_gobs_logs(conn, log_msg, "info", config_id) - add_new_job(conn, cron_id, job_type_id, config_id, run_config_id) diff --git a/gobs/pym/mysql_querys.py b/gobs/pym/mysql_querys.py index 66c21f0..f179d26 100644 --- a/gobs/pym/mysql_querys.py +++ b/gobs/pym/mysql_querys.py @@ -55,48 +55,6 @@ def update_job_list(connection, status, job_id): connection.commit() cursor.close() -def get_cron_jobs(connection, config_id): - cursor = connection.cursor() - sqlQ = 'SELECT cron_id FROM cron WHERE config_id = %s AND TIMESTAMPDIFF(MINUTES, time_stamp, NOW()) >= time_when' - cursor.execute(sqlQ, (config_id,)) - entries = cursor.fetchall() - cursor.close() - if entries is None: - return None - cron_id_list = [] - for cron_id in entries: - cron_id_list.append(cron_id[0]) - return sorted(cron_id_list) - -def check_jobs(connection, job_type_id, config_id, run_config_id): - cursor = connection.cursor() - sqlQ = "SELECT job_id FROM jobs WHERE job_type_id = %s AND config_id = %s AND run_config_id = %s AND (status = 'Runing' OR status = 'Waiting')" - cursor.execute(sqlQ) - entries = cursor.fetchone() - cursor.close() - if entries is None: - return False - return True - -def get_cron_info(connection, cron_id): - cursor = connection.cursor() - sqlQ = 'SELECT job_type_id, run_config_id FROM cron WHERE cron_id = %s' - cursor.execute(sqlQ) - entries = cursor.fetchone() - cursor.close() - job_type_id = entries[0] - run_config_id = entries[1] - return job_type_id, run_config_id - -def add_new_job(connection, cron_id, job_type_id, config_id, run_config_id): - cursor = connection.cursor() - sqlQ1 = "INSERT INTO jobs (job_type_id, user, config_id, run_config_id) VALUES ( %s, 'cron', %s, %s)" - sqlQ2 = 'UPDATE cron SET time_stamp = NOW() WHERE cron_id = %s' - cursor.execute(sqlQ1, (job_type_id, config_id, run_config_id,)) - cursor.execute(sqlQ2(cron_id,)) - connection.commit() - cursor.close() - # Queryes to handel the configs* tables def get_config_list_all(connection): cursor = connection.cursor()