1 |
commit: 1d87c4f414d5a231b9951246b97daee36d8190a7 |
2 |
Author: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 25 14:27:31 2015 +0000 |
4 |
Commit: Gilles Dartiguelongue <eva <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Jun 26 22:14:41 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=1d87c4f4 |
7 |
|
8 |
scripts/gen_archlist: switch logging to logging module |
9 |
|
10 |
The output changes a bit but thanks for dictConfig, it can be re-added |
11 |
with a proper formatter class later on. |
12 |
|
13 |
scripts/gen_archlist.py | 69 ++++++++++++++++++++++++++++++++----------------- |
14 |
1 file changed, 45 insertions(+), 24 deletions(-) |
15 |
|
16 |
diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py |
17 |
index b362a5d..1c4c027 100755 |
18 |
--- a/scripts/gen_archlist.py |
19 |
+++ b/scripts/gen_archlist.py |
20 |
@@ -25,11 +25,15 @@ from __future__ import division, print_function |
21 |
|
22 |
import argparse |
23 |
import collections |
24 |
+import logging |
25 |
+import logging.config |
26 |
import os |
27 |
import sys |
28 |
|
29 |
import portage |
30 |
|
31 |
+logger = logging.getLogger('gen_archlist') |
32 |
+ |
33 |
############# |
34 |
# Constants # |
35 |
############# |
36 |
@@ -92,13 +96,6 @@ def debug(*strings): |
37 |
ewarn(flatten(strings)) |
38 |
|
39 |
|
40 |
-def nothing_to_be_done(atom, type='cpv'): |
41 |
- if STABLE: |
42 |
- debug('%s %s: already stable, ignoring...' % (type, atom)) |
43 |
- else: |
44 |
- debug('%s %s: already keyworded, ignoring...' % (type, atom)) |
45 |
- |
46 |
- |
47 |
def make_unstable(kws): |
48 |
"""Transform `kws` into a list of unstable keywords.""" |
49 |
return set([ |
50 |
@@ -182,8 +179,7 @@ def get_best_deps(cpv, kws, release=None): |
51 |
|
52 |
cpvs = match_wanted_atoms(atom, release) |
53 |
if not cpvs: |
54 |
- if DEBUG: |
55 |
- debug('We encountered an irrelevant atom: %s' % atom) |
56 |
+ logger.debug('Encountered an irrelevant atom: %s', atom) |
57 |
continue |
58 |
|
59 |
best_cpv_kws = ['', []] |
60 |
@@ -196,9 +192,8 @@ def get_best_deps(cpv, kws, release=None): |
61 |
) |
62 |
if cur_unstable_kws.intersection(unstable_kws) != unstable_kws: |
63 |
best_cpv_kws[0] = 'none' |
64 |
- if DEBUG: |
65 |
- debug('Insufficient unstable keywords in: %s' % |
66 |
- candidate_cpv) |
67 |
+ logger.debug('Insufficiant unstable keywords in: %s', |
68 |
+ candidate_cpv) |
69 |
continue |
70 |
|
71 |
candidate_kws = get_kws(candidate_cpv, arches=kws) |
72 |
@@ -216,8 +211,8 @@ def get_best_deps(cpv, kws, release=None): |
73 |
best_cpv_kws = [candidate_cpv, []] |
74 |
|
75 |
if best_cpv_kws[0] == 'alreadythere': |
76 |
- if DEBUG: |
77 |
- nothing_to_be_done(atom, type='dep') |
78 |
+ logger.debug('DEP %s is already %s, ignoring', atom, |
79 |
+ 'stable' if STABLE else 'keyworded') |
80 |
continue |
81 |
elif best_cpv_kws[0] == 'none': |
82 |
continue |
83 |
@@ -324,8 +319,9 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release): |
84 |
# So... let's just stabilize it on all arches we can, and ignore for |
85 |
# keywording since we have no idea about that. |
86 |
if not STABLE: |
87 |
- debug('MEH') |
88 |
- nothing_to_be_done(cpv, type='dep') |
89 |
+ logger.warn('MEH') |
90 |
+ logger.info('DEP %s is already %s, ignoring', cpv, |
91 |
+ 'stable' if STABLE else 'keyworded') |
92 |
return None |
93 |
|
94 |
wanted = get_kws(cpv, arches=make_unstable(kws_aim)) |
95 |
@@ -334,8 +330,7 @@ def gen_cpv_kws(cpv, kws_aim, depgraph, check_dependencies, new_release): |
96 |
|
97 |
if check_dependencies and not issystempackage(cpv): |
98 |
deps = get_best_deps(cpv, wanted, release=new_release) |
99 |
- if EXTREME_DEBUG: |
100 |
- debug('The deps of %s are %s' % (cpv, deps)) |
101 |
+ logger.debug('Dependencies of %s are: %s', cpv, deps) |
102 |
|
103 |
for dep in deps: |
104 |
if dep in depgraph: |
105 |
@@ -442,10 +437,8 @@ def main(): |
106 |
parser = argparse.ArgumentParser( |
107 |
description='Generate a stabilization request for multiple packages' |
108 |
) |
109 |
- parser.add_argument('-d', '--debug', action='store_true', default=False, |
110 |
+ parser.add_argument('-v', '--verbose', action='count', |
111 |
help='Make output more verbose') |
112 |
- parser.add_argument('--extreme-debug', action='store_true', default=False, |
113 |
- help='Make output even more verbose') |
114 |
parser.add_argument('--check-dependencies', |
115 |
action='store_true', default=False, |
116 |
help='Check dependencies are keyworded and if not,' |
117 |
@@ -463,6 +456,33 @@ def main(): |
118 |
' to be stabilized') |
119 |
args = parser.parse_args() |
120 |
|
121 |
+ args.verbose = min(max(args.verbose, 0), 2) |
122 |
+ logging.config.dictConfig({ |
123 |
+ 'version': 1, |
124 |
+ 'disable_existing_loggers': True, |
125 |
+ 'formatters': { |
126 |
+ 'brief': {'format': '%(message)s'}, |
127 |
+ }, |
128 |
+ 'handlers': { |
129 |
+ 'console': { |
130 |
+ 'class': 'logging.StreamHandler', |
131 |
+ 'level': 'DEBUG', |
132 |
+ 'formatter': 'brief', |
133 |
+ 'stream': 'ext://sys.stdout', |
134 |
+ }, |
135 |
+ }, |
136 |
+ 'loggers': { |
137 |
+ 'gen_archlist': { |
138 |
+ 'handlers': ['console'], |
139 |
+ 'level': [logging.WARN, logging.INFO, |
140 |
+ logging.DEBUG][args.verbose], |
141 |
+ }, |
142 |
+ }, |
143 |
+ 'root': { |
144 |
+ 'handler': ['console'], |
145 |
+ }, |
146 |
+ }) |
147 |
+ |
148 |
ALL_CPV_KWS = [] |
149 |
for i in open(args.file).readlines(): |
150 |
cp = i[:-1] |
151 |
@@ -480,19 +500,20 @@ def main(): |
152 |
|
153 |
for cpv in get_per_slot_cpvs(cpvs): |
154 |
if not cpv: |
155 |
- debug('%s: Invalid cpv' % cpv) |
156 |
+ logger.warn('%s is an invalid CPV', cpv) |
157 |
continue |
158 |
|
159 |
kws_missing = max_kws(cpv, release=args.old_version) |
160 |
if kws_missing is None: |
161 |
- debug('No versions with stable keywords for %s' % cpv) |
162 |
+ logger.info('No versions with stable keywords for %s', cpv) |
163 |
# No cpv with stable keywords => select latest |
164 |
arches = make_unstable(ARCHES) |
165 |
kws_missing = [kw[1:] for kw in get_kws(cpv, arches)] |
166 |
|
167 |
elif not kws_missing: |
168 |
# Current cpv has the max keywords => nothing to do |
169 |
- nothing_to_be_done(cpv) |
170 |
+ logger.info('CPV %s is already %s, ignoring', cpv, |
171 |
+ 'stable' if STABLE else 'keyworded') |
172 |
continue |
173 |
|
174 |
ALL_CPV_KWS.append( |