diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2023-10-20 23:32:40 +0545 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-10-21 00:56:10 +0000 |
| commit | ae824fb2fc2770c84cc34c1956e4c76c8c972860 (patch) | |
| tree | 4f8ec44e29c7401b99b3aef1b28a2104a0a86221 /subcmds | |
| parent | 034950b9eebacd6598ea518a0b254845bc806ab6 (diff) | |
| download | git-repo-ae824fb2fc2770c84cc34c1956e4c76c8c972860.tar.gz | |
cleanup: convert exceptions to OSError
In Python 3, these exceptions were merged into OSError, so switch
everything over to that.
Change-Id: If876a28b692de5aa5c62a3bdc8c000793ce52c63
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390376
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Mike Frysinger <vapier@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/sync.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 23098972..8460bcec 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -21,7 +21,6 @@ import multiprocessing | |||
| 21 | import netrc | 21 | import netrc |
| 22 | import optparse | 22 | import optparse |
| 23 | import os | 23 | import os |
| 24 | import socket | ||
| 25 | import sys | 24 | import sys |
| 26 | import tempfile | 25 | import tempfile |
| 27 | import time | 26 | import time |
| @@ -1376,7 +1375,7 @@ later is required to fix a server side protocol bug. | |||
| 1376 | else: | 1375 | else: |
| 1377 | try: | 1376 | try: |
| 1378 | info = netrc.netrc() | 1377 | info = netrc.netrc() |
| 1379 | except IOError: | 1378 | except OSError: |
| 1380 | # .netrc file does not exist or could not be opened. | 1379 | # .netrc file does not exist or could not be opened. |
| 1381 | pass | 1380 | pass |
| 1382 | else: | 1381 | else: |
| @@ -1435,7 +1434,7 @@ later is required to fix a server side protocol bug. | |||
| 1435 | try: | 1434 | try: |
| 1436 | with open(smart_sync_manifest_path, "w") as f: | 1435 | with open(smart_sync_manifest_path, "w") as f: |
| 1437 | f.write(manifest_str) | 1436 | f.write(manifest_str) |
| 1438 | except IOError as e: | 1437 | except OSError as e: |
| 1439 | raise SmartSyncError( | 1438 | raise SmartSyncError( |
| 1440 | "error: cannot write manifest to %s:\n%s" | 1439 | "error: cannot write manifest to %s:\n%s" |
| 1441 | % (smart_sync_manifest_path, e), | 1440 | % (smart_sync_manifest_path, e), |
| @@ -1446,7 +1445,7 @@ later is required to fix a server side protocol bug. | |||
| 1446 | raise SmartSyncError( | 1445 | raise SmartSyncError( |
| 1447 | "error: manifest server RPC call failed: %s" % manifest_str | 1446 | "error: manifest server RPC call failed: %s" % manifest_str |
| 1448 | ) | 1447 | ) |
| 1449 | except (socket.error, IOError, xmlrpc.client.Fault) as e: | 1448 | except (OSError, xmlrpc.client.Fault) as e: |
| 1450 | raise SmartSyncError( | 1449 | raise SmartSyncError( |
| 1451 | "error: cannot connect to manifest server %s:\n%s" | 1450 | "error: cannot connect to manifest server %s:\n%s" |
| 1452 | % (manifest.manifest_server, e), | 1451 | % (manifest.manifest_server, e), |
| @@ -1931,7 +1930,7 @@ class _FetchTimes: | |||
| 1931 | try: | 1930 | try: |
| 1932 | with open(self._path) as f: | 1931 | with open(self._path) as f: |
| 1933 | self._saved = json.load(f) | 1932 | self._saved = json.load(f) |
| 1934 | except (IOError, ValueError): | 1933 | except (OSError, ValueError): |
| 1935 | platform_utils.remove(self._path, missing_ok=True) | 1934 | platform_utils.remove(self._path, missing_ok=True) |
| 1936 | self._saved = {} | 1935 | self._saved = {} |
| 1937 | 1936 | ||
| @@ -1947,7 +1946,7 @@ class _FetchTimes: | |||
| 1947 | try: | 1946 | try: |
| 1948 | with open(self._path, "w") as f: | 1947 | with open(self._path, "w") as f: |
| 1949 | json.dump(self._seen, f, indent=2) | 1948 | json.dump(self._seen, f, indent=2) |
| 1950 | except (IOError, TypeError): | 1949 | except (OSError, TypeError): |
| 1951 | platform_utils.remove(self._path, missing_ok=True) | 1950 | platform_utils.remove(self._path, missing_ok=True) |
| 1952 | 1951 | ||
| 1953 | 1952 | ||
| @@ -1994,7 +1993,7 @@ class LocalSyncState: | |||
| 1994 | try: | 1993 | try: |
| 1995 | with open(self._path) as f: | 1994 | with open(self._path) as f: |
| 1996 | self._state = json.load(f) | 1995 | self._state = json.load(f) |
| 1997 | except (IOError, ValueError): | 1996 | except (OSError, ValueError): |
| 1998 | platform_utils.remove(self._path, missing_ok=True) | 1997 | platform_utils.remove(self._path, missing_ok=True) |
| 1999 | self._state = {} | 1998 | self._state = {} |
| 2000 | 1999 | ||
| @@ -2004,7 +2003,7 @@ class LocalSyncState: | |||
| 2004 | try: | 2003 | try: |
| 2005 | with open(self._path, "w") as f: | 2004 | with open(self._path, "w") as f: |
| 2006 | json.dump(self._state, f, indent=2) | 2005 | json.dump(self._state, f, indent=2) |
| 2007 | except (IOError, TypeError): | 2006 | except (OSError, TypeError): |
| 2008 | platform_utils.remove(self._path, missing_ok=True) | 2007 | platform_utils.remove(self._path, missing_ok=True) |
| 2009 | 2008 | ||
| 2010 | def PruneRemovedProjects(self): | 2009 | def PruneRemovedProjects(self): |
| @@ -2137,7 +2136,7 @@ class PersistentTransport(xmlrpc.client.Transport): | |||
| 2137 | try: | 2136 | try: |
| 2138 | p.feed(data) | 2137 | p.feed(data) |
| 2139 | except xml.parsers.expat.ExpatError as e: | 2138 | except xml.parsers.expat.ExpatError as e: |
| 2140 | raise IOError( | 2139 | raise OSError( |
| 2141 | f"Parsing the manifest failed: {e}\n" | 2140 | f"Parsing the manifest failed: {e}\n" |
| 2142 | f"Please report this to your manifest server admin.\n" | 2141 | f"Please report this to your manifest server admin.\n" |
| 2143 | f'Here is the full response:\n{data.decode("utf-8")}' | 2142 | f'Here is the full response:\n{data.decode("utf-8")}' |
