|
12 | 12 | from simple_logger.logger import get_logger |
13 | 13 |
|
14 | 14 | from class_generator.constants import DEFINITIONS_FILE, RESOURCES_MAPPING_FILE, SCHEMA_DIR |
15 | | -from class_generator.utils import execute_parallel_with_mapping, execute_parallel_tasks |
| 15 | +from class_generator.utils import execute_parallel_tasks, execute_parallel_with_mapping |
16 | 16 | from ocp_resources.utils.archive_utils import save_json_archive |
17 | 17 | from ocp_resources.utils.schema_validator import SchemaValidator |
18 | 18 |
|
|
22 | 22 | class ClusterVersionError(Exception): |
23 | 23 | """Raised when there are issues with cluster version operations.""" |
24 | 24 |
|
25 | | - pass |
26 | | - |
27 | 25 |
|
28 | 26 | def get_client_binary() -> str: |
29 | 27 | """Determine whether to use 'oc' or 'kubectl' binary.""" |
@@ -138,7 +136,7 @@ def check_and_update_cluster_version(client: str) -> bool: |
138 | 136 | try: |
139 | 137 | with open(cluster_version_file, "r") as fd: |
140 | 138 | last_cluster_version_generated = fd.read().strip() |
141 | | - except (FileNotFoundError, IOError): |
| 139 | + except (OSError, FileNotFoundError): |
142 | 140 | # Treat missing file as first run - use baseline version that allows updates |
143 | 141 | last_cluster_version_generated = "v0.0.0" |
144 | 142 | LOGGER.info("Cluster version file not found - treating as first run with baseline version v0.0.0") |
@@ -1360,10 +1358,10 @@ def write_schema_files( |
1360 | 1358 | # Ensure schema directory exists |
1361 | 1359 | try: |
1362 | 1360 | Path(SCHEMA_DIR).mkdir(parents=True, exist_ok=True) |
1363 | | - except (OSError, IOError) as e: |
| 1361 | + except OSError as e: |
1364 | 1362 | error_msg = f"Failed to create schema directory {SCHEMA_DIR}: {e}" |
1365 | 1363 | LOGGER.error(error_msg) |
1366 | | - raise IOError(error_msg) from e |
| 1364 | + raise OSError(error_msg) from e |
1367 | 1365 |
|
1368 | 1366 | # Fetch missing core definitions if schemas are available |
1369 | 1367 | if schemas: |
@@ -1400,18 +1398,18 @@ def write_schema_files( |
1400 | 1398 | with open(definitions_file, "w") as fd: |
1401 | 1399 | json.dump(definitions_data, fd, indent=2, sort_keys=True) |
1402 | 1400 | LOGGER.info(f"Written {len(definitions)} definitions to {definitions_file}") |
1403 | | - except (OSError, IOError, TypeError) as e: |
| 1401 | + except (OSError, TypeError) as e: |
1404 | 1402 | error_msg = f"Failed to write definitions file {definitions_file}: {e}" |
1405 | 1403 | LOGGER.error(error_msg) |
1406 | | - raise IOError(error_msg) from e |
| 1404 | + raise OSError(error_msg) from e |
1407 | 1405 |
|
1408 | 1406 | # Write and archive resources mapping |
1409 | 1407 | try: |
1410 | 1408 | save_json_archive(resources_mapping, RESOURCES_MAPPING_FILE) |
1411 | | - except (OSError, IOError, TypeError) as e: |
| 1409 | + except (OSError, TypeError) as e: |
1412 | 1410 | error_msg = f"Failed to save and archive resources mapping file {RESOURCES_MAPPING_FILE}: {e}" |
1413 | 1411 | LOGGER.error(error_msg) |
1414 | | - raise IOError(error_msg) from e |
| 1412 | + raise OSError(error_msg) from e |
1415 | 1413 |
|
1416 | 1414 |
|
1417 | 1415 | @dataclasses.dataclass |
@@ -1527,7 +1525,7 @@ def _handle_no_schemas_case() -> None: |
1527 | 1525 | existing_definitions_data = json.load(fd) |
1528 | 1526 | definitions = existing_definitions_data.get("definitions", {}) |
1529 | 1527 | LOGGER.info(f"Found {len(definitions)} existing definitions that will be preserved") |
1530 | | - except (FileNotFoundError, IOError, json.JSONDecodeError): |
| 1528 | + except (OSError, FileNotFoundError, json.JSONDecodeError): |
1531 | 1529 | LOGGER.debug("Could not load existing definitions file. No existing definitions to preserve.") |
1532 | 1530 |
|
1533 | 1531 |
|
|
0 commit comments