1 |
commit: ba4481d37cbedc5700b5ea21c5a1897389ecc1cb |
2 |
Author: dol-sen <brian.dolbec <AT> gmail <DOT> com> |
3 |
AuthorDate: Fri Jul 29 06:10:33 2011 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Fri Jul 29 06:10:33 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ba4481d3 |
7 |
|
8 |
fix the overly noisy output for unsupported overlay types. Thank you fuzzyray for reporting. |
9 |
|
10 |
--- |
11 |
layman/dbbase.py | 2 +- |
12 |
layman/overlays/bzr.py | 2 +- |
13 |
layman/overlays/cvs.py | 2 +- |
14 |
layman/overlays/darcs.py | 2 +- |
15 |
layman/overlays/g_common.py | 3 ++- |
16 |
layman/overlays/git.py | 2 +- |
17 |
layman/overlays/mercurial.py | 2 +- |
18 |
layman/overlays/rsync.py | 2 +- |
19 |
layman/overlays/source.py | 33 +++++++++++++++++++++++---------- |
20 |
layman/overlays/svn.py | 2 +- |
21 |
layman/overlays/tar.py | 2 +- |
22 |
11 files changed, 34 insertions(+), 20 deletions(-) |
23 |
|
24 |
diff --git a/layman/dbbase.py b/layman/dbbase.py |
25 |
index b6b0e6d..4714d5f 100644 |
26 |
--- a/layman/dbbase.py |
27 |
+++ b/layman/dbbase.py |
28 |
@@ -75,7 +75,7 @@ class BrokenOverlayCatalog(ValueError): |
29 |
# |
30 |
#------------------------------------------------------------------------------- |
31 |
|
32 |
-class DbBase: |
33 |
+class DbBase(object): |
34 |
''' Handle a list of overlays.''' |
35 |
|
36 |
def __init__(self, config, paths=None, ignore = 0, |
37 |
|
38 |
diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py |
39 |
index 5844176..40e5b81 100644 |
40 |
--- a/layman/overlays/bzr.py |
41 |
+++ b/layman/overlays/bzr.py |
42 |
@@ -89,4 +89,4 @@ class BzrOverlay(OverlaySource): |
43 |
|
44 |
return require_supported( |
45 |
[(self.command(), 'bzr', 'dev-vcs/bzr'),], |
46 |
- self.output.error) |
47 |
+ self.output.warn) |
48 |
|
49 |
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py |
50 |
index 83981e5..c902250 100644 |
51 |
--- a/layman/overlays/cvs.py |
52 |
+++ b/layman/overlays/cvs.py |
53 |
@@ -114,4 +114,4 @@ class CvsOverlay(OverlaySource): |
54 |
|
55 |
return require_supported( |
56 |
[(self.command(), 'cvs', 'dev-vcs/cvs'),], |
57 |
- self.output.error) |
58 |
+ self.output.warn) |
59 |
|
60 |
diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py |
61 |
index 02ef3c7..3e24ebe 100644 |
62 |
--- a/layman/overlays/darcs.py |
63 |
+++ b/layman/overlays/darcs.py |
64 |
@@ -90,4 +90,4 @@ class DarcsOverlay(OverlaySource): |
65 |
|
66 |
return require_supported( |
67 |
[(self.command(), 'darcs', 'dev-vcs/darcs'),], |
68 |
- self.output.error) |
69 |
+ self.output.warn) |
70 |
|
71 |
diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py |
72 |
index df7c4a4..cb162e8 100644 |
73 |
--- a/layman/overlays/g_common.py |
74 |
+++ b/layman/overlays/g_common.py |
75 |
@@ -84,4 +84,5 @@ class GCommonOverlay(OverlaySource): |
76 |
'app-portage/g-common'), |
77 |
('/usr/share/g-common/drivers/'+self.driver+'.cfg', |
78 |
'g-common for '+self.driver, |
79 |
- 'app-portage/g-'+self.driver),], self.output.error) |
80 |
+ 'app-portage/g-'+self.driver),], |
81 |
+ self.output.warn) |
82 |
|
83 |
diff --git a/layman/overlays/git.py b/layman/overlays/git.py |
84 |
index 5775277..f6a350f 100644 |
85 |
--- a/layman/overlays/git.py |
86 |
+++ b/layman/overlays/git.py |
87 |
@@ -95,4 +95,4 @@ class GitOverlay(OverlaySource): |
88 |
|
89 |
return require_supported( |
90 |
[(self.command(), 'git', 'dev-vcs/git'),], |
91 |
- self.output.error) |
92 |
+ self.output.warn) |
93 |
|
94 |
diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py |
95 |
index ebaf635..5247e78 100644 |
96 |
--- a/layman/overlays/mercurial.py |
97 |
+++ b/layman/overlays/mercurial.py |
98 |
@@ -90,4 +90,4 @@ class MercurialOverlay(OverlaySource): |
99 |
|
100 |
return require_supported( |
101 |
[(self.command(), 'mercurial', 'dev-vcs/mercurial'),], |
102 |
- self.output.error) |
103 |
+ self.output.warn) |
104 |
|
105 |
diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py |
106 |
index f4537ed..3c03ae2 100644 |
107 |
--- a/layman/overlays/rsync.py |
108 |
+++ b/layman/overlays/rsync.py |
109 |
@@ -86,4 +86,4 @@ class RsyncOverlay(OverlaySource): |
110 |
|
111 |
return require_supported( |
112 |
[(self.command(), 'rsync', 'net-misc/rsync'),], |
113 |
- self.output.error) |
114 |
+ self.output.warn) |
115 |
|
116 |
diff --git a/layman/overlays/source.py b/layman/overlays/source.py |
117 |
index b833fd2..083beb6 100644 |
118 |
--- a/layman/overlays/source.py |
119 |
+++ b/layman/overlays/source.py |
120 |
@@ -20,11 +20,21 @@ import shutil |
121 |
import subprocess |
122 |
from layman.utils import path |
123 |
|
124 |
- |
125 |
-def _resolve_command(command, error_output): |
126 |
+supported_cache = {} |
127 |
+ |
128 |
+def _supported(key, check_supported=None): |
129 |
+ """internal caching function that checks tracks any |
130 |
+ un-supported/supported repo types.""" |
131 |
+ if key is None: |
132 |
+ return False |
133 |
+ if key not in supported_cache: |
134 |
+ supported_cache[key] = check_supported() |
135 |
+ return supported_cache[key] |
136 |
+ |
137 |
+def _resolve_command(command, _output): |
138 |
if os.path.isabs(command): |
139 |
if not os.path.exists(command): |
140 |
- error_output('Program "%s" not found' % command) |
141 |
+ _output('Program "%s" not found' % command, 6) |
142 |
return ('File', None) |
143 |
return ('File', command) |
144 |
else: |
145 |
@@ -34,18 +44,18 @@ def _resolve_command(command, error_output): |
146 |
f = os.path.join(d, command) |
147 |
if os.path.exists(f): |
148 |
return ('Command', f) |
149 |
- error_output('Cound not resolve command ' +\ |
150 |
- '"%s" based on PATH "%s"' % (command, env_path)) |
151 |
+ _output('Cound not resolve command ' +\ |
152 |
+ '"%s" based on PATH "%s"' % (command, env_path), 6) |
153 |
return ('Command', None) |
154 |
|
155 |
|
156 |
-def require_supported(binaries, error_output): |
157 |
+def require_supported(binaries, _output): |
158 |
for command, mtype, package in binaries: |
159 |
- kind, path = _resolve_command(command, error_output) |
160 |
+ kind, path = _resolve_command(command, _output) |
161 |
if not path: |
162 |
- error_output(kind + ' ' + command + ' seems to be missing!' |
163 |
+ _output(kind + ' ' + command + ' seems to be missing!' |
164 |
' Overlay type "' + mtype + '" not support' |
165 |
- 'ed. Did you emerge ' + package + '?') |
166 |
+ 'ed. Did you emerge ' + package + '?', 6) |
167 |
return False |
168 |
return True |
169 |
|
170 |
@@ -106,7 +116,10 @@ class OverlaySource(object): |
171 |
|
172 |
def is_supported(self): |
173 |
'''Is the overlay type supported?''' |
174 |
- return self.supported() |
175 |
+ return _supported(self.get_type_key(), self.supported) |
176 |
+ |
177 |
+ def get_type_key(self): |
178 |
+ return '%s' % self.__class__.type_key |
179 |
|
180 |
def command(self): |
181 |
return self.config['%s_command' % self.__class__.type_key] |
182 |
|
183 |
diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py |
184 |
index 59b6284..97f03d6 100644 |
185 |
--- a/layman/overlays/svn.py |
186 |
+++ b/layman/overlays/svn.py |
187 |
@@ -103,4 +103,4 @@ class SvnOverlay(OverlaySource): |
188 |
|
189 |
return require_supported( |
190 |
[(self.command(), 'svn','dev-vcs/subversion'),], |
191 |
- self.output.error) |
192 |
+ self.output.warn) |
193 |
|
194 |
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py |
195 |
index dc2234a..7be2ed2 100644 |
196 |
--- a/layman/overlays/tar.py |
197 |
+++ b/layman/overlays/tar.py |
198 |
@@ -210,7 +210,7 @@ class TarOverlay(OverlaySource): |
199 |
|
200 |
return require_supported( |
201 |
[(self.command(), 'tar', 'app-arch/tar'), ], |
202 |
- self.output.error) |
203 |
+ self.output.warn) |
204 |
|
205 |
if __name__ == '__main__': |
206 |
import doctest |