1 |
commit: b88c47083fb9c5a0ab68a7749ceb9dca1428806c |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Dec 2 00:05:35 2012 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Dec 2 00:05:35 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=b88c4708 |
7 |
|
8 |
refix check_make_conf |
9 |
|
10 |
--- |
11 |
gobs/pym/check_setup.py | 81 ++++++++++++++++++++++------------------------- |
12 |
1 files changed, 38 insertions(+), 43 deletions(-) |
13 |
|
14 |
diff --git a/gobs/pym/check_setup.py b/gobs/pym/check_setup.py |
15 |
index b1a185c..7c9fcad 100644 |
16 |
--- a/gobs/pym/check_setup.py |
17 |
+++ b/gobs/pym/check_setup.py |
18 |
@@ -17,49 +17,44 @@ if CM.getName()=='pgsql': |
19 |
from gobs.pgsql_querys import * |
20 |
|
21 |
def check_make_conf(): |
22 |
- # Get the config list |
23 |
- conn=CM.getConnection() |
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_id_list_all: |
29 |
- attDict={} |
30 |
- # Set the config dir |
31 |
- config = get_config(conn, config_id): |
32 |
- check_config_dir = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config + "/" |
33 |
- make_conf_file = check_config_dir + "etc/portage/make.conf" |
34 |
- # Check if we can open the file and close it |
35 |
- # Check if we have some error in the file (portage.util.getconfig) |
36 |
- # Check if we envorment error with the config (settings.validate) |
37 |
- try: |
38 |
- open_make_conf = open(make_conf_file) |
39 |
- open_make_conf.close() |
40 |
- portage.util.getconfig(make_conf_file, tolerant=0, allow_sourcing=False, expand=True) |
41 |
- mysettings = portage.config(config_root = check_config_dir) |
42 |
- mysettings.validate() |
43 |
- # With errors we update the db on the config and disable the config |
44 |
- except Exception as e: |
45 |
- attDict['config_error'] = e |
46 |
- attDict['active'] = 'False' |
47 |
- log_msg = "%s FAIL!" % (config,) |
48 |
- add_gobs_logs(conn, log_msg, "info", config_profile) |
49 |
- else: |
50 |
- attDict['config_error'] = '' |
51 |
- attDict['active'] = 'True' |
52 |
- log_msg = "%s PASS" % (config,) |
53 |
- add_gobs_logs(conn, log_msg, "info", config_profile) |
54 |
- # Get the checksum of make.conf |
55 |
- make_conf_checksum_tree = portage.checksum.sha256hash(make_conf_file)[0] |
56 |
- log_msg = "make.conf checksum is %s on %s" % (make_conf_checksum_tree, config,) |
57 |
- add_gobs_logs(conn, log_msg, "info", config_profile) |
58 |
- attDict['make_conf_text'] = get_file_text(make_conf_file) |
59 |
- attDict['make_conf_checksum_tree'] = make_conf_checksum_tree |
60 |
- configsDict[config_id]=attDict |
61 |
- update_make_conf(conn, configsDict) |
62 |
- log_msg = "Checking configs for changes and errors ... Done" |
63 |
- add_gobs_logs(conn, log_msg, "info", config_profile) |
64 |
- CM.putConnection(conn) |
65 |
+ # Get the config list |
66 |
+ conn=CM.getConnection() |
67 |
+ config_id_list_all = get_config_list_all(conn) |
68 |
+ log_msg = "Checking configs for changes and errors" |
69 |
+ add_gobs_logs(conn, log_msg, "info", config_profile) |
70 |
+ configsDict = {} |
71 |
+ for config_id in config_id_list_all: |
72 |
+ attDict={} |
73 |
+ # Set the config dir |
74 |
+ config = get_config(conn, config_id): |
75 |
+ check_config_dir = "/var/cache/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config + "/" |
76 |
+ make_conf_file = check_config_dir + "etc/portage/make.conf" |
77 |
+ # Check if we can take a checksum on it. |
78 |
+ # Check if we have some error in the file. (portage.util.getconfig) |
79 |
+ # Check if we envorment error with the config. (settings.validate) |
80 |
+ try: |
81 |
+ make_conf_checksum_tree = portage.checksum.sha256hash(make_conf_file)[0] |
82 |
+ portage.util.getconfig(make_conf_file, tolerant=0, allow_sourcing=False, expand=True) |
83 |
+ mysettings = portage.config(config_root = check_config_dir) |
84 |
+ mysettings.validate() |
85 |
+ # With errors we update the db on the config and disable the config |
86 |
+ except Exception as e: |
87 |
+ attDict['config_error'] = e |
88 |
+ attDict['active'] = 'False' |
89 |
+ log_msg = "%s FAIL!" % (config,) |
90 |
+ add_gobs_logs(conn, log_msg, "info", config_profile) |
91 |
+ else: |
92 |
+ attDict['config_error'] = '' |
93 |
+ attDict['active'] = 'True' |
94 |
+ log_msg = "%s PASS" % (config,) |
95 |
+ add_gobs_logs(conn, log_msg, "info", config_profile) |
96 |
+ attDict['make_conf_text'] = get_file_text(make_conf_file) |
97 |
+ attDict['make_conf_checksum_tree'] = make_conf_checksum_tree |
98 |
+ configsDict[config_id]=attDict |
99 |
+ update_make_conf(conn, configsDict) |
100 |
+ log_msg = "Checking configs for changes and errors ... Done" |
101 |
+ add_gobs_logs(conn, log_msg, "info", config_profile) |
102 |
+ CM.putConnection(conn) |
103 |
|
104 |
def check_make_conf_guest(config_profile): |
105 |
conn=CM.getConnection() |