1 |
commit: 9d85fe87e992047e0972eceb82c0a81e819ed6f7 |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Apr 29 13:09:55 2012 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 29 13:09:55 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=9d85fe87 |
7 |
|
8 |
start of the job host deamon |
9 |
|
10 |
--- |
11 |
gobs/bin/gobs_host_jobs | 45 +++++++++++++++++++++++++++++++++++++++++++++ |
12 |
gobs/pym/pgsql.py | 18 ++++++++++++++++++ |
13 |
2 files changed, 63 insertions(+), 0 deletions(-) |
14 |
|
15 |
diff --git a/gobs/bin/gobs_host_jobs b/gobs/bin/gobs_host_jobs |
16 |
new file mode 100755 |
17 |
index 0000000..856041c |
18 |
--- /dev/null |
19 |
+++ b/gobs/bin/gobs_host_jobs |
20 |
@@ -0,0 +1,45 @@ |
21 |
+#!/usr/bin/python |
22 |
+# Copyright 2006-2011 Gentoo Foundation |
23 |
+# Distributed under the terms of the GNU General Public License v2 |
24 |
+ |
25 |
+from __future__ import print_function |
26 |
+ |
27 |
+from gobs.init_setup_profile import setup_profile_main |
28 |
+from gobs.readconf import get_conf_settings |
29 |
+reader = get_conf_settings() |
30 |
+gobs_settings_dict=reader.read_gobs_settings_all() |
31 |
+ |
32 |
+# make a CM |
33 |
+from gobs.ConnectionManager import connectionManager |
34 |
+CM=connectionManager(gobs_settings_dict) |
35 |
+#selectively import the pgsql/mysql querys |
36 |
+if CM.getName()=='pgsql': |
37 |
+ from gobs.pgsql import * |
38 |
+# import logging |
39 |
+ |
40 |
+def main(): |
41 |
+ # Main |
42 |
+ config_profile = gobs_settings_dict['gobs_config'] |
43 |
+ # Logging |
44 |
+ #logging.basicConfig(filename=gobs_settings_dict['gobs_logfile'], \ |
45 |
+ # format='%(levelname)s: %(asctime)s %(message)s', level=logging.INFO) |
46 |
+ conn = CM.getConnection() |
47 |
+ CM.putConnection(conn) |
48 |
+ repeat = True |
49 |
+ while repeat: |
50 |
+ conn = CM.getConnection() |
51 |
+ job jobid = check_job_list(conn, config_profile) |
52 |
+ print("job jobid:" + job + " " + jobid) |
53 |
+ if job is None: |
54 |
+ time.sleep(60) |
55 |
+ CM.putConnection(conn) |
56 |
+ continue |
57 |
+ else: |
58 |
+ update_job_list("Runing", jobid) |
59 |
+ repeat = False |
60 |
+ CM.putConnection(conn) |
61 |
+ time.sleep(60) |
62 |
+ connectionManager.closeAllConnections() |
63 |
+ |
64 |
+if __name__ == "__main__": |
65 |
+ main() |
66 |
\ No newline at end of file |
67 |
|
68 |
diff --git a/gobs/pym/pgsql.py b/gobs/pym/pgsql.py |
69 |
index db70f6c..21c204d 100644 |
70 |
--- a/gobs/pym/pgsql.py |
71 |
+++ b/gobs/pym/pgsql.py |
72 |
@@ -636,3 +636,21 @@ def add_fail_querue_dict(connection, fail_querue_dict): |
73 |
|
74 |
def make_conf_error(connection,config_profile): |
75 |
pass |
76 |
+ |
77 |
+def check_job_list(connection, config_profile): |
78 |
+ cursor = connection.cursor() |
79 |
+ sqlQ1 = 'SELECT idnr FROM config WHERE id = %s' |
80 |
+ sqlQ2 = "SELECT job, jobnr FROM jobs_list WHERE status = 'Waiting' AND config_id = %s" |
81 |
+ cursor.execute(sqlQ1, (config_profile,)) |
82 |
+ config_nr = cursor.fetchone() |
83 |
+ cursor.execute(sqlQ2, (config_nr,)) |
84 |
+ job jobid = cursor.fetchone() |
85 |
+ if job is None: |
86 |
+ return None None |
87 |
+ return job jobid |
88 |
+ |
89 |
+def update_job_list(status, jobid) |
90 |
+ cursor = connection.cursor() |
91 |
+ sqlQ = 'UPDATE jobs_list SET ststus = %s WHERE jobid = %s' |
92 |
+ cursor.execute(sqlQ, (status, jobid,)) |
93 |
+ connection.commit() |