1 |
commit: b76f0d127571cc4a43a6ebe7b93e0ead2c356bcc |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 1 23:57:54 2012 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Dec 1 23:57:54 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=b76f0d12 |
7 |
|
8 |
fix check_make_conf |
9 |
|
10 |
--- |
11 |
gobs/pym/check_setup.py | 15 ++++++++------- |
12 |
gobs/pym/pgsql_querys.py | 11 +++++++++-- |
13 |
2 files changed, 17 insertions(+), 9 deletions(-) |
14 |
|
15 |
diff --git a/gobs/pym/check_setup.py b/gobs/pym/check_setup.py |
16 |
index 4d62909..b1a185c 100644 |
17 |
--- a/gobs/pym/check_setup.py |
18 |
+++ b/gobs/pym/check_setup.py |
19 |
@@ -19,14 +19,15 @@ if CM.getName()=='pgsql': |
20 |
def check_make_conf(): |
21 |
# Get the config list |
22 |
conn=CM.getConnection() |
23 |
- config_list_all = get_config_list_all(conn) |
24 |
+ config_id_list_all = get_config_list_all(conn) |
25 |
log_msg = "Checking configs for changes and errors" |
26 |
add_gobs_logs(conn, log_msg, "info", config_profile) |
27 |
configsDict = {} |
28 |
- for config_id in config_list_all: |
29 |
+ for config_id in config_id_list_all: |
30 |
attDict={} |
31 |
# Set the config dir |
32 |
- check_config_dir = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_id[0] + "/" |
33 |
+ config = get_config(conn, config_id): |
34 |
+ check_config_dir = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config + "/" |
35 |
make_conf_file = check_config_dir + "etc/portage/make.conf" |
36 |
# Check if we can open the file and close it |
37 |
# Check if we have some error in the file (portage.util.getconfig) |
38 |
@@ -41,20 +42,20 @@ def check_make_conf(): |
39 |
except Exception as e: |
40 |
attDict['config_error'] = e |
41 |
attDict['active'] = 'False' |
42 |
- log_msg = "%s FAIL!" % (config_id[0],) |
43 |
+ log_msg = "%s FAIL!" % (config,) |
44 |
add_gobs_logs(conn, log_msg, "info", config_profile) |
45 |
else: |
46 |
attDict['config_error'] = '' |
47 |
attDict['active'] = 'True' |
48 |
- log_msg = "%s PASS" % (config_id[0],) |
49 |
+ log_msg = "%s PASS" % (config,) |
50 |
add_gobs_logs(conn, log_msg, "info", config_profile) |
51 |
# Get the checksum of make.conf |
52 |
make_conf_checksum_tree = portage.checksum.sha256hash(make_conf_file)[0] |
53 |
- log_msg = "make.conf checksum is %s on %s" % (make_conf_checksum_tree, config_id[0],) |
54 |
+ log_msg = "make.conf checksum is %s on %s" % (make_conf_checksum_tree, config,) |
55 |
add_gobs_logs(conn, log_msg, "info", config_profile) |
56 |
attDict['make_conf_text'] = get_file_text(make_conf_file) |
57 |
attDict['make_conf_checksum_tree'] = make_conf_checksum_tree |
58 |
- configsDict[config_id[0]]=attDict |
59 |
+ configsDict[config_id]=attDict |
60 |
update_make_conf(conn, configsDict) |
61 |
log_msg = "Checking configs for changes and errors ... Done" |
62 |
add_gobs_logs(conn, log_msg, "info", config_profile) |
63 |
|
64 |
diff --git a/gobs/pym/pgsql_querys.py b/gobs/pym/pgsql_querys.py |
65 |
index b74d18c..3c0813d 100644 |
66 |
--- a/gobs/pym/pgsql_querys.py |
67 |
+++ b/gobs/pym/pgsql_querys.py |
68 |
@@ -37,14 +37,21 @@ def update_job_list(connection, status, job_id): |
69 |
# Queryes to handel the configs* tables |
70 |
def get_config_list_all(connection): |
71 |
cursor = connection.cursor() |
72 |
- sqlQ = 'SELECT config FROM configs' |
73 |
+ sqlQ = 'SELECT config_id FROM configs' |
74 |
cursor.execute(sqlQ) |
75 |
entries = cursor.fetchall() |
76 |
return entries |
77 |
|
78 |
+def get_config(connection, config_id): |
79 |
+ cursor = connection.cursor() |
80 |
+ sqlQ ='SELECT config FROM configs WHERE config_id = %s' |
81 |
+ cursor.execute(sqlQ, (config_id,)) |
82 |
+ config = cursor.fetchone() |
83 |
+ return config[0] |
84 |
+ |
85 |
def update_make_conf(connection, configsDict): |
86 |
cursor = connection.cursor() |
87 |
- sqlQ = 'UPDATE configs_metadata SET checksum = %s, make_conf_text = %s, active = %s, config_error = %s WHERE config_id = (SELECT config_id FROM configs WHERE config = %s)' |
88 |
+ sqlQ = 'UPDATE configs_metadata SET checksum = %s, make_conf_text = %s, active = %s, config_error = %s WHERE config_id = %s' |
89 |
for k, v in configsDict.iteritems(): |
90 |
cursor.execute(sqlQ, (v['make_conf_checksum_tree'], v['make_conf_text'], v['active'], v['config_error'], k,)) |
91 |
connection.commit() |