This fixes avoid ctrl+c to be ignored in some parts of the code.
Florent Viard authored on 2020/04/09 10:44:19... | ... |
@@ -483,7 +483,7 @@ class CloudFront(object): |
483 | 483 |
fp.write(deunicodise("\n".join(paths)+"\n")) |
484 | 484 |
warning("Request to invalidate %d paths (max 999 supported)" % len(paths)) |
485 | 485 |
warning("All the paths are now saved in: %s" % tmp_filename) |
486 |
- except: |
|
486 |
+ except Exception: |
|
487 | 487 |
pass |
488 | 488 |
raise ParameterError("Too many paths to invalidate") |
489 | 489 |
|
... | ... |
@@ -803,7 +803,7 @@ class Cmd(object): |
803 | 803 |
try: |
804 | 804 |
for i in inval_list['inval_list'].info['InvalidationSummary']: |
805 | 805 |
requests.append("/".join(["cf:/", cfuri.dist_id(), i["Id"]])) |
806 |
- except: |
|
806 |
+ except Exception: |
|
807 | 807 |
continue |
808 | 808 |
for req in requests: |
809 | 809 |
cfuri = S3Uri(req) |
... | ... |
@@ -285,7 +285,7 @@ class Config(object): |
285 | 285 |
if self._access_token_refresh: |
286 | 286 |
try: |
287 | 287 |
self.role_config() |
288 |
- except: |
|
288 |
+ except Exception: |
|
289 | 289 |
warning("Could not refresh role") |
290 | 290 |
|
291 | 291 |
def aws_credential_file(self): |
... | ... |
@@ -442,7 +442,7 @@ class Config(object): |
442 | 442 |
shift = 0 |
443 | 443 |
try: |
444 | 444 |
value = shift and int(value[:-1]) << shift or int(value) |
445 |
- except: |
|
445 |
+ except Exception: |
|
446 | 446 |
raise ValueError("Config: value of option %s must have suffix m, k, or nothing, not '%s'" % (option, value)) |
447 | 447 |
|
448 | 448 |
## allow yes/no, true/false, on/off and 1/0 for boolean options |
... | ... |
@@ -276,7 +276,7 @@ __all__.append("s3_quote") |
276 | 276 |
def checksum_sha256_file(filename, offset=0, size=None): |
277 | 277 |
try: |
278 | 278 |
hash = sha256() |
279 |
- except: |
|
279 |
+ except Exception: |
|
280 | 280 |
# fallback to Crypto SHA256 module |
281 | 281 |
hash = sha256.new() |
282 | 282 |
with open(deunicodise(filename),'rb') as f: |
... | ... |
@@ -296,7 +296,7 @@ def checksum_sha256_file(filename, offset=0, size=None): |
296 | 296 |
def checksum_sha256_buffer(buffer, offset=0, size=None): |
297 | 297 |
try: |
298 | 298 |
hash = sha256() |
299 |
- except: |
|
299 |
+ except Exception: |
|
300 | 300 |
# fallback to Crypto SHA256 module |
301 | 301 |
hash = sha256.new() |
302 | 302 |
if size is None: |
... | ... |
@@ -35,7 +35,7 @@ def _os_walk_unicode(top): |
35 | 35 |
''' |
36 | 36 |
try: |
37 | 37 |
names = os.listdir(deunicodise(top)) |
38 |
- except: |
|
38 |
+ except Exception: |
|
39 | 39 |
return |
40 | 40 |
|
41 | 41 |
dirs, nondirs = [], [] |
... | ... |
@@ -246,7 +246,7 @@ def fetch_local_list(args, is_src = False, recursive = None): |
246 | 246 |
try: |
247 | 247 |
uid = os.geteuid() |
248 | 248 |
gid = os.getegid() |
249 |
- except: |
|
249 |
+ except Exception: |
|
250 | 250 |
uid = 0 |
251 | 251 |
gid = 0 |
252 | 252 |
loc_list["-"] = { |
... | ... |
@@ -694,7 +694,7 @@ class S3(object): |
694 | 694 |
# an md5. |
695 | 695 |
try: |
696 | 696 |
info = self.object_info(uri) |
697 |
- except: |
|
697 |
+ except Exception: |
|
698 | 698 |
info = None |
699 | 699 |
|
700 | 700 |
if info is not None: |
... | ... |
@@ -1507,7 +1507,7 @@ class S3(object): |
1507 | 1507 |
response["data"] = http_response.read() |
1508 | 1508 |
response["size"] = size_total |
1509 | 1509 |
known_error = True |
1510 |
- except: |
|
1510 |
+ except Exception: |
|
1511 | 1511 |
error("Cannot retrieve any response status before encountering an EPIPE or ECONNRESET exception") |
1512 | 1512 |
if not known_error: |
1513 | 1513 |
warning("Upload failed: %s (%s)" % (resource['uri'], e)) |
... | ... |
@@ -51,7 +51,7 @@ from logging import debug, info, warning, error |
51 | 51 |
|
52 | 52 |
try: |
53 | 53 |
import htmlentitydefs |
54 |
-except: |
|
54 |
+except Exception: |
|
55 | 55 |
# python 3 support |
56 | 56 |
import html.entities as htmlentitydefs |
57 | 57 |
|
... | ... |
@@ -1369,7 +1369,7 @@ def cmd_sync_remote2local(args): |
1369 | 1369 |
# Try to remove the temp file if it exists |
1370 | 1370 |
if chkptfname_b: |
1371 | 1371 |
os.unlink(chkptfname_b) |
1372 |
- except: |
|
1372 |
+ except Exception: |
|
1373 | 1373 |
pass |
1374 | 1374 |
|
1375 | 1375 |
if allow_partial and not cfg.stop_on_error: |
... | ... |
@@ -1466,7 +1466,7 @@ def cmd_sync_remote2local(args): |
1466 | 1466 |
finally: |
1467 | 1467 |
try: |
1468 | 1468 |
os.remove(chkptfname_b) |
1469 |
- except: |
|
1469 |
+ except Exception: |
|
1470 | 1470 |
pass |
1471 | 1471 |
|
1472 | 1472 |
speed_fmt = formatSize(response["speed"], human_readable = True, floating_point = True) |
... | ... |
@@ -1560,7 +1560,7 @@ def remote_copy(s3, copy_pairs, destination_base, uploaded_objects_list=None): |
1560 | 1560 |
output(u"remote copy: '%s' -> '%s'" % (dst1, dst2)) |
1561 | 1561 |
if uploaded_objects_list is not None: |
1562 | 1562 |
uploaded_objects_list.append(dst2) |
1563 |
- except: |
|
1563 |
+ except Exception: |
|
1564 | 1564 |
warning(u"Unable to remote copy files '%s' -> '%s'" % (dst1_uri, dst2_uri)) |
1565 | 1565 |
failed_copy_list[dst2] = src_obj |
1566 | 1566 |
return (len(copy_pairs), saved_bytes, failed_copy_list) |
... | ... |
@@ -1589,7 +1589,7 @@ def _build_attr_header(local_list, src): |
1589 | 1589 |
elif attr != "md5": |
1590 | 1590 |
try: |
1591 | 1591 |
val = getattr(local_list[src]['sr'], 'st_' + attr) |
1592 |
- except: |
|
1592 |
+ except Exception: |
|
1593 | 1593 |
val = None |
1594 | 1594 |
if val is not None: |
1595 | 1595 |
attrs[attr] = val |
... | ... |
@@ -2114,7 +2114,7 @@ def cmd_list_multipart(args): |
2114 | 2114 |
for mpupload in parseNodes(tree): |
2115 | 2115 |
try: |
2116 | 2116 |
output(u"%s\t%s\t%s\t%s" % (mpupload['LastModified'], mpupload['PartNumber'], mpupload['ETag'], mpupload['Size'])) |
2117 |
- except: |
|
2117 |
+ except Exception: |
|
2118 | 2118 |
pass |
2119 | 2119 |
return EX_OK |
2120 | 2120 |
|
... | ... |
@@ -2615,7 +2615,7 @@ class OptionS3ACL(Option): |
2615 | 2615 |
else: |
2616 | 2616 |
raise OptionValueError("option %s: invalid S3 ACL permission: %s (valid values: %s)" % |
2617 | 2617 |
(opt, permission, ", ".join(permissions))) |
2618 |
- except: |
|
2618 |
+ except Exception: |
|
2619 | 2619 |
raise OptionValueError("option %s: invalid S3 ACL format: %r" % (opt, value)) |
2620 | 2620 |
|
2621 | 2621 |
class OptionAll(OptionMimeType, OptionS3ACL): |