1 |
commit: 0664515fa7da71204eafdb832e9be74edfee0be9 |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Jan 3 05:33:17 2016 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jan 30 06:51:58 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0664515f |
7 |
|
8 |
repoman: Enable verbosity option to be useful for setting the logging level |
9 |
|
10 |
Verbosity option was not being used internally. |
11 |
Convert debug print's added to proper debug messages. |
12 |
|
13 |
pym/repoman/main.py | 13 ++++++++++--- |
14 |
pym/repoman/scanner.py | 35 +++++++++++++++++++---------------- |
15 |
2 files changed, 29 insertions(+), 19 deletions(-) |
16 |
|
17 |
diff --git a/pym/repoman/main.py b/pym/repoman/main.py |
18 |
index 890e034..6921005 100755 |
19 |
--- a/pym/repoman/main.py |
20 |
+++ b/pym/repoman/main.py |
21 |
@@ -19,7 +19,6 @@ from portage import os |
22 |
import portage.checksum |
23 |
import portage.const |
24 |
import portage.repository.config |
25 |
-from portage import util |
26 |
from portage.output import create_color_func, nocolor |
27 |
from portage.output import ConsoleStyleFile, StyleWriter |
28 |
from portage.util import formatter |
29 |
@@ -37,13 +36,14 @@ from repoman.modules.vcs.settings import VCSSettings |
30 |
if sys.hexversion >= 0x3000000: |
31 |
basestring = str |
32 |
|
33 |
-util.initialize_logger() |
34 |
- |
35 |
bad = create_color_func("BAD") |
36 |
|
37 |
# A sane umask is needed for files that portage creates. |
38 |
os.umask(0o22) |
39 |
|
40 |
+LOGLEVEL = logging.WARNING |
41 |
+portage.util.initialize_logger(LOGLEVEL) |
42 |
+ |
43 |
|
44 |
def repoman_main(argv): |
45 |
config_root = os.environ.get("PORTAGE_CONFIGROOT") |
46 |
@@ -61,6 +61,13 @@ def repoman_main(argv): |
47 |
print("Portage", portage.VERSION) |
48 |
sys.exit(0) |
49 |
|
50 |
+ logger = logging.getLogger() |
51 |
+ |
52 |
+ if options.verbosity > 0: |
53 |
+ logger.setLevel(LOGLEVEL - 10 * options.verbosity) |
54 |
+ else: |
55 |
+ logger.setLevel(LOGLEVEL) |
56 |
+ |
57 |
if options.experimental_inherit == 'y': |
58 |
# This is experimental, so it's non-fatal. |
59 |
qawarnings.add("inherit.missing") |
60 |
|
61 |
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py |
62 |
index 4dd5408..8623812 100644 |
63 |
--- a/pym/repoman/scanner.py |
64 |
+++ b/pym/repoman/scanner.py |
65 |
@@ -19,13 +19,13 @@ from portage.module import Modules |
66 |
|
67 |
MODULES_PATH = os.path.join(os.path.dirname(__file__), "modules", "scan") |
68 |
# initial development debug info |
69 |
-#print("module path:", path) |
70 |
+logging.debug("module path: %s", MODULES_PATH) |
71 |
|
72 |
MODULE_CONTROLLER = Modules(path=MODULES_PATH, namepath="repoman.modules.scan") |
73 |
|
74 |
-# initial development debug info |
75 |
-#print(module_controller.module_names) |
76 |
MODULE_NAMES = MODULE_CONTROLLER.module_names[:] |
77 |
+# initial development debug info |
78 |
+logging.debug("module_names: %s", MODULE_NAMES) |
79 |
|
80 |
|
81 |
class Scanner(object): |
82 |
@@ -200,7 +200,7 @@ class Scanner(object): |
83 |
for mod in ['manifests', 'isebuild', 'keywords', 'files', 'vcsstatus', |
84 |
'fetches', 'pkgmetadata']: |
85 |
mod_class = MODULE_CONTROLLER.get_class(mod) |
86 |
- print("Initializing class name:", mod_class.__name__) |
87 |
+ logging.debug("Initializing class name: %s", mod_class.__name__) |
88 |
self.modules[mod_class.__name__] = mod_class(**self.kwargs) |
89 |
|
90 |
def scan_pkgs(self, can_force): |
91 |
@@ -208,7 +208,7 @@ class Scanner(object): |
92 |
for xpkg in self.effective_scanlist: |
93 |
xpkg_continue = False |
94 |
# ebuilds and digests added to cvs respectively. |
95 |
- logging.info("checking package %s" % xpkg) |
96 |
+ logging.info("checking package %s", xpkg) |
97 |
# save memory by discarding xmatch caches from previous package(s) |
98 |
self.caches['arch_xmatch'].clear() |
99 |
self.eadded = [] |
100 |
@@ -236,7 +236,7 @@ class Scanner(object): |
101 |
# need to set it up for ==> self.modules or some other ordered list |
102 |
for mod in ['Manifests', 'IsEbuild', 'KeywordChecks', 'FileChecks', |
103 |
'VCSStatus', 'FetchChecks', 'PkgMetadata']: |
104 |
- print("scan_pkgs(): module:", mod) |
105 |
+ logging.debug("scan_pkgs; module: %s", mod) |
106 |
do_it, functions = self.modules[mod].runInPkgs |
107 |
if do_it: |
108 |
for func in functions: |
109 |
@@ -300,7 +300,7 @@ class Scanner(object): |
110 |
logging.debug("do_it: %s, functions: %s", do_it, [x.__name__ for x in functions]) |
111 |
if do_it: |
112 |
for func in functions: |
113 |
- print("\tRunning function:", func) |
114 |
+ logging.debug("\tRunning function: %s", func) |
115 |
rdata = func(**dynamic_data) |
116 |
if rdata.get('continue', False): |
117 |
# If we can't access all the metadata then it's totally unsafe to |
118 |
@@ -309,14 +309,17 @@ class Scanner(object): |
119 |
# metadata leads to false positives for several checks, and false |
120 |
# positives confuse users. |
121 |
y_ebuild_continue = True |
122 |
+ # logging.debug("\t>>> Continuing") |
123 |
break |
124 |
- #print("rdata:", rdata) |
125 |
+ # logging.debug("rdata: %s", rdata) |
126 |
dynamic_data.update(rdata) |
127 |
- #print("dynamic_data", dynamic_data) |
128 |
+ # logging.debug("dynamic_data: %s", dynamic_data) |
129 |
|
130 |
if y_ebuild_continue: |
131 |
continue |
132 |
|
133 |
+ logging.debug("Finished ebuild plugin loop, continuing...") |
134 |
+ |
135 |
# Final checks |
136 |
# initialize per pkg plugin final checks here |
137 |
# need to set it up for ==> self.modules_list or some other ordered list |
138 |
@@ -324,22 +327,22 @@ class Scanner(object): |
139 |
for mod in [('unused', 'UnusedChecks')]: |
140 |
if mod[0]: |
141 |
mod_class = MODULE_CONTROLLER.get_class(mod[0]) |
142 |
- print("Initializing class name:", mod_class.__name__) |
143 |
+ logging.debug("Initializing class name: %s", mod_class.__name__) |
144 |
self.modules[mod[1]] = mod_class(**self.kwargs) |
145 |
- print("scan_ebuilds final checks: module:", mod[1]) |
146 |
+ logging.debug("scan_ebuilds final checks: module: %s", mod[1]) |
147 |
do_it, functions = self.modules[mod[1]].runInFinal |
148 |
- # print("do_it", do_it, "functions", functions) |
149 |
+ logging.debug("do_it: %s, functions: %s", do_it, [x.__name__ for x in functions]) |
150 |
if do_it: |
151 |
for func in functions: |
152 |
- print("\tRunning function:", func) |
153 |
+ logging.debug("\tRunning function: %s", func) |
154 |
rdata = func(**dynamic_data) |
155 |
if rdata.get('continue', False): |
156 |
xpkg_complete = True |
157 |
- print("\t>>> Continuing") |
158 |
+ # logging.debug("\t>>> Continuing") |
159 |
break |
160 |
- #print("rdata:", rdata) |
161 |
+ # logging.debug("rdata: %s", rdata) |
162 |
dynamic_data.update(rdata) |
163 |
- #print("dynamic_data", dynamic_data) |
164 |
+ # logging.debug("dynamic_data: %s", dynamic_data) |
165 |
|
166 |
if xpkg_complete: |
167 |
return |