1 |
commit: d0339cb228c16eb491d489a2276e254bacb41c81 |
2 |
Author: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
3 |
AuthorDate: Sun Mar 27 03:39:37 2011 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Sun Mar 27 03:39:37 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d0339cb2 |
7 |
|
8 |
migrate except ... as |
9 |
|
10 |
--- |
11 |
layman/api.py | 14 +++++++------- |
12 |
layman/cli.py | 4 ++-- |
13 |
layman/db.py | 8 ++++---- |
14 |
layman/dbbase.py | 6 +++--- |
15 |
layman/makeconf.py | 4 ++-- |
16 |
layman/overlays/overlay.py | 2 +- |
17 |
layman/overlays/tar.py | 10 +++++----- |
18 |
layman/utils.py | 2 +- |
19 |
8 files changed, 25 insertions(+), 25 deletions(-) |
20 |
|
21 |
diff --git a/layman/api.py b/layman/api.py |
22 |
index 9dfb1a3..9178dbe 100644 |
23 |
--- a/layman/api.py |
24 |
+++ b/layman/api.py |
25 |
@@ -116,7 +116,7 @@ class LaymanAPI(object): |
26 |
try: |
27 |
self._get_installed_db().delete(self._get_installed_db().select(ovl)) |
28 |
results.append(True) |
29 |
- except Exception, e: |
30 |
+ except Exception as e: |
31 |
self._error(ERROR_INTERNAL_ERROR, |
32 |
"Failed to disable repository '"+ovl+"':\n"+str(e)) |
33 |
results.append(False) |
34 |
@@ -147,7 +147,7 @@ class LaymanAPI(object): |
35 |
try: |
36 |
self._get_installed_db().add(self._get_remote_db().select(ovl), quiet=True) |
37 |
results.append(True) |
38 |
- except Exception, e: |
39 |
+ except Exception as e: |
40 |
self._error(ERROR_INTERNAL_ERROR, |
41 |
"Failed to enable repository '"+ovl+"' : "+str(e)) |
42 |
results.append(False) |
43 |
@@ -198,7 +198,7 @@ class LaymanAPI(object): |
44 |
continue |
45 |
try: |
46 |
overlay = db.select(ovl) |
47 |
- except UnknownOverlayException, error: |
48 |
+ except UnknownOverlayException as error: |
49 |
self._error(error) |
50 |
result[ovl] = ('', False, False) |
51 |
else: |
52 |
@@ -252,7 +252,7 @@ class LaymanAPI(object): |
53 |
overlay = db.select(ovl) |
54 |
#print("overlay = ", ovl) |
55 |
#print("!!!", overlay) |
56 |
- except UnknownOverlayException, error: |
57 |
+ except UnknownOverlayException as error: |
58 |
#print("ERRORS", str(error)) |
59 |
self._error(error) |
60 |
result[ovl] = ('', False, False) |
61 |
@@ -301,7 +301,7 @@ class LaymanAPI(object): |
62 |
for ovl in repos: |
63 |
try: |
64 |
odb = db.select(ovl) |
65 |
- except UnknownOverlayException, error: |
66 |
+ except UnknownOverlayException as error: |
67 |
self._error(UnknownOverlayException(error)) |
68 |
continue |
69 |
|
70 |
@@ -344,7 +344,7 @@ class LaymanAPI(object): |
71 |
try: |
72 |
db.sync(ovl, self.config['quiet']) |
73 |
success.append((ovl,'Successfully synchronized overlay "' + ovl + '".')) |
74 |
- except Exception, error: |
75 |
+ except Exception as error: |
76 |
fatals.append((ovl, |
77 |
'Failed to sync overlay "' + ovl + '".\nError was: ' |
78 |
+ str(error))) |
79 |
@@ -374,7 +374,7 @@ class LaymanAPI(object): |
80 |
"""Fetches the latest remote overlay list""" |
81 |
try: |
82 |
self._get_remote_db().cache() |
83 |
- except Exception, error: |
84 |
+ except Exception as error: |
85 |
self._error('Failed to fetch overlay list!\n Original Error was: ' |
86 |
+ str(error)) |
87 |
return False |
88 |
|
89 |
diff --git a/layman/cli.py b/layman/cli.py |
90 |
index 1187ef2..d58c4ff 100644 |
91 |
--- a/layman/cli.py |
92 |
+++ b/layman/cli.py |
93 |
@@ -162,7 +162,7 @@ class Main(object): |
94 |
try: |
95 |
new_umask = int(umask, 8) |
96 |
old_umask = os.umask(new_umask) |
97 |
- except Exception, error: |
98 |
+ except Exception as error: |
99 |
self.output.die('Failed setting to umask "' + umask + |
100 |
'"!\nError was: ' + str(error)) |
101 |
|
102 |
@@ -173,7 +173,7 @@ class Main(object): |
103 |
if action[0] in self.config.keys(): |
104 |
try: |
105 |
result += getattr(self, action[1])() |
106 |
- except Exception, error: |
107 |
+ except Exception as error: |
108 |
for _error in self.api.get_errors(): |
109 |
self.output.error(_error) |
110 |
result = -1 # So it cannot remain 0, i.e. success |
111 |
|
112 |
diff --git a/layman/db.py b/layman/db.py |
113 |
index ed2bb2e..6e3cba4 100644 |
114 |
--- a/layman/db.py |
115 |
+++ b/layman/db.py |
116 |
@@ -303,7 +303,7 @@ class RemoteDB(DbBase): |
117 |
if not os.path.exists(os.path.dirname(mpath)): |
118 |
try: |
119 |
os.makedirs(os.path.dirname(mpath)) |
120 |
- except OSError, error: |
121 |
+ except OSError as error: |
122 |
raise OSError('Failed to create layman storage direct' |
123 |
+ 'ory ' + os.path.dirname(mpath) + '\n' |
124 |
+ 'Error was:' + str(error)) |
125 |
@@ -312,7 +312,7 @@ class RemoteDB(DbBase): |
126 |
# file is intact and can be parsed |
127 |
try: |
128 |
self.read(olist, origin=url) |
129 |
- except Exception, error: |
130 |
+ except Exception as error: |
131 |
raise IOError('Failed to parse the overlays list fetched fr' |
132 |
'om ' + url + '\nThis means that the download' |
133 |
'ed file is somehow corrupt or there was a pr' |
134 |
@@ -325,12 +325,12 @@ class RemoteDB(DbBase): |
135 |
out_file.write(olist) |
136 |
out_file.close() |
137 |
|
138 |
- except Exception, error: |
139 |
+ except Exception as error: |
140 |
raise IOError('Failed to temporarily cache overlays list in' |
141 |
' ' + mpath + '\nError was:\n' + str(error)) |
142 |
|
143 |
|
144 |
- except IOError, error: |
145 |
+ except IOError as error: |
146 |
self.output.warn('Failed to update the overlay list from: ' |
147 |
+ url + '\nError was:\n' + str(error)) |
148 |
|
149 |
|
150 |
diff --git a/layman/dbbase.py b/layman/dbbase.py |
151 |
index 02aeb9d..5c45cb1 100644 |
152 |
--- a/layman/dbbase.py |
153 |
+++ b/layman/dbbase.py |
154 |
@@ -116,7 +116,7 @@ class DbBase: |
155 |
try: |
156 |
document = open(path, 'r').read() |
157 |
|
158 |
- except Exception, error: |
159 |
+ except Exception as error: |
160 |
if not ignore_init_read_errors: |
161 |
self.output.error('Failed to read the overlay list at ("' |
162 |
+ path + '")') |
163 |
@@ -146,7 +146,7 @@ class DbBase: |
164 |
''' |
165 |
try: |
166 |
document = ET.fromstring(text) |
167 |
- except xml.parsers.expat.ExpatError, error: |
168 |
+ except xml.parsers.expat.ExpatError as error: |
169 |
raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint()) |
170 |
|
171 |
overlays = document.findall('overlay') + \ |
172 |
@@ -216,7 +216,7 @@ class DbBase: |
173 |
""") |
174 |
tree.write(f, encoding='utf-8') |
175 |
f.close() |
176 |
- except Exception, error: |
177 |
+ except Exception as error: |
178 |
raise Exception('Failed to write to local overlays file: ' |
179 |
+ path + '\nError was:\n' + str(error)) |
180 |
|
181 |
|
182 |
diff --git a/layman/makeconf.py b/layman/makeconf.py |
183 |
index b6f5d90..1dd2b56 100644 |
184 |
--- a/layman/makeconf.py |
185 |
+++ b/layman/makeconf.py |
186 |
@@ -257,7 +257,7 @@ class MakeConf: |
187 |
|
188 |
make_conf.close() |
189 |
|
190 |
- except Exception, error: |
191 |
+ except Exception as error: |
192 |
self.output.error('MakeConf: write(); Failed to write "' |
193 |
+ self.path + '".\nError was:\n' + str(error)) |
194 |
return False |
195 |
@@ -274,7 +274,7 @@ class MakeConf: |
196 |
|
197 |
make_conf.close() |
198 |
|
199 |
- except Exception, error: |
200 |
+ except Exception as error: |
201 |
self.output.error('MakeConf: content(); Failed to read "' + |
202 |
self.path + '".\nError was:\n' + str(error)) |
203 |
raise error |
204 |
|
205 |
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py |
206 |
index aada4a2..b99c052 100644 |
207 |
--- a/layman/overlays/overlay.py |
208 |
+++ b/layman/overlays/overlay.py |
209 |
@@ -405,7 +405,7 @@ class Overlay(object): |
210 |
# Worked, throw other sources away |
211 |
self.sources = [s] |
212 |
break |
213 |
- except Exception, error: |
214 |
+ except Exception as error: |
215 |
self.output.warn(str(error), 4) |
216 |
first_s = False |
217 |
return res |
218 |
|
219 |
diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py |
220 |
index 9d59b71..204a626 100644 |
221 |
--- a/layman/overlays/tar.py |
222 |
+++ b/layman/overlays/tar.py |
223 |
@@ -107,7 +107,7 @@ class TarOverlay(OverlaySource): |
224 |
|
225 |
try: |
226 |
tar = urllib2.urlopen(tar_url).read() |
227 |
- except Exception, error: |
228 |
+ except Exception as error: |
229 |
raise Exception('Failed to fetch the tar package from: ' |
230 |
+ self.src + '\nError was:' + str(error)) |
231 |
|
232 |
@@ -117,7 +117,7 @@ class TarOverlay(OverlaySource): |
233 |
out_file = open(pkg, 'w') |
234 |
out_file.write(tar) |
235 |
out_file.close() |
236 |
- except Exception, error: |
237 |
+ except Exception as error: |
238 |
raise Exception('Failed to store tar package in ' |
239 |
+ pkg + '\nError was:' + str(error)) |
240 |
|
241 |
@@ -136,7 +136,7 @@ class TarOverlay(OverlaySource): |
242 |
try: |
243 |
self.output.info('Deleting directory "%s"' % folder, 2) |
244 |
shutil.rmtree(folder) |
245 |
- except Exception, error: |
246 |
+ except Exception as error: |
247 |
raise Exception('Failed to remove unnecessary tar structure "' |
248 |
+ folder + '"\nError was:' + str(error)) |
249 |
|
250 |
@@ -145,7 +145,7 @@ class TarOverlay(OverlaySource): |
251 |
try: |
252 |
result = self._extract(base=base, tar_url=self.src, |
253 |
dest_dir=temp_path) |
254 |
- except Exception, error: |
255 |
+ except Exception as error: |
256 |
try_to_wipe(temp_path) |
257 |
raise error |
258 |
|
259 |
@@ -161,7 +161,7 @@ class TarOverlay(OverlaySource): |
260 |
|
261 |
try: |
262 |
os.rename(source, final_path) |
263 |
- except Exception, error: |
264 |
+ except Exception as error: |
265 |
raise Exception('Failed to rename tar subdirectory ' + |
266 |
source + ' to ' + final_path + |
267 |
'\nError was:' + str(error)) |
268 |
|
269 |
diff --git a/layman/utils.py b/layman/utils.py |
270 |
index 86524ef..03ddb45 100644 |
271 |
--- a/layman/utils.py |
272 |
+++ b/layman/utils.py |
273 |
@@ -167,7 +167,7 @@ def delete_empty_directory(mdir, output=OUT): |
274 |
output.info('Deleting _empty_ directory "%s"' % mdir, 2) |
275 |
try: |
276 |
os.rmdir(mdir) |
277 |
- except OSError, error: |
278 |
+ except OSError as error: |
279 |
output.warn(str(error)) |
280 |
else: |
281 |
output.warn('Insufficient permissions to delete _empty_ folder "%s".' % mdir) |