Skip to content

Commit

Permalink
Core: Clean unnecessary logs
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghua committed Aug 21, 2024
1 parent c6e8806 commit 93648c9
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions tosfs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,13 @@ def _bucket_info(self, bucket: str) -> dict:
self.tos_client.head_bucket(bucket)
return self._fill_bucket_info(bucket)
except tos.exceptions.TosClientError as e:
logger.error("Tosfs failed with client error: %s", e)
raise e
except tos.exceptions.TosServerError as e:
if e.status_code == SERVER_RESPONSE_CODE_NOT_FOUND:
raise FileNotFoundError(bucket) from e
else:
logger.error("Tosfs failed with server error: %s", e)
raise e
except Exception as e:
logger.error("Tosfs failed with unknown error: %s", e)
raise TosfsError(f"Tosfs failed with unknown error: {e}") from e

def _object_info(
Expand Down Expand Up @@ -376,16 +373,13 @@ def _object_info(
"ContentType": out.content_type or "",
}
except tos.exceptions.TosClientError as e:
logger.error("Tosfs failed with client error: %s", e)
raise e
except tos.exceptions.TosServerError as e:
if e.status_code == SERVER_RESPONSE_CODE_NOT_FOUND:
pass
else:
logger.error("Tosfs failed with server error: %s", e)
raise e
except Exception as e:
logger.error("Tosfs failed with unknown error: %s", e)
raise TosfsError(f"Tosfs failed with unknown error: {e}") from e

return {}
Expand All @@ -411,15 +405,12 @@ def _try_dir_info(self, bucket: str, key: str, path: str, fullpath: str) -> dict

raise FileNotFoundError(path)
except tos.exceptions.TosClientError as e:
logger.error("Tosfs failed with client error: %s", e)
raise e
except tos.exceptions.TosServerError as e:
logger.error("Tosfs failed with server error: %s", e)
raise e
except FileNotFoundError as e:
raise e
except Exception as e:
logger.error("Tosfs failed with unknown error: %s", e)
raise TosfsError(f"Tosfs failed with unknown error: {e}") from e

def _lsbuckets(self, refresh: bool = False) -> List[dict]:
Expand Down Expand Up @@ -456,13 +447,10 @@ def _lsbuckets(self, refresh: bool = False) -> List[dict]:
try:
resp = self.tos_client.list_buckets()
except tos.exceptions.TosClientError as e:
logger.error("Tosfs failed with client error: %s", e)
raise e
except tos.exceptions.TosServerError as e:
logger.error("Tosfs failed with server error: %s", e)
raise e
except Exception as e:
logger.error("Tosfs failed with unknown error: %s", e)
raise TosfsError(f"Tosfs failed with unknown error: {e}") from e

buckets = [self._fill_bucket_info(bucket.name) for bucket in resp.buckets]
Expand Down Expand Up @@ -631,17 +619,10 @@ def _listdir(

return all_results
except tos.exceptions.TosClientError as e:
logger.error(
"Tosfs failed with client error, message:%s, cause: %s",
e.message,
e.cause,
)
raise e
except tos.exceptions.TosServerError as e:
logger.error("Tosfs failed with server error: %s", e)
raise e
except Exception as e:
logger.error("Tosfs failed with unknown error: %s", e)
raise TosfsError(f"Tosfs failed with unknown error: {e}") from e

def _rm(self, path: str) -> None:
Expand All @@ -651,13 +632,10 @@ def _rm(self, path: str) -> None:
try:
self.tos_client.delete_object(bucket, key)
except tos.exceptions.TosClientError as e:
logger.error("Tosfs failed with client error: %s", e)
raise e
except tos.exceptions.TosServerError as e:
logger.error("Tosfs failed with server error: %s", e)
raise e
except Exception as e:
logger.error("Tosfs failed with unknown error: %s", e)
raise TosfsError(f"Tosfs failed with unknown error: {e}") from e

def _split_path(self, path: str) -> Tuple[str, str, Optional[str]]:
Expand Down

0 comments on commit 93648c9

Please sign in to comment.