Skip to content

Commit 28b5fb3

Browse files
committed
bump version to 0.1.6 and handle 429 error in SharePoint service
1 parent f9d7133 commit 28b5fb3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "office365-service"
3-
version = "0.1.4"
3+
version = "0.1.6"
44
description = "Add your description here"
55
readme = "README.md"
66
authors = [

src/office365_service/sharepoint_service.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from office365.sharepoint.client_context import ClientContext
88
from office365.sharepoint.files.file import File
99
from office365.sharepoint.folders.folder import Folder
10-
from office365.sharepoint.sharing.links.kind import SharingLinkKind
1110

1211

1312
def handle_sharepoint_errors(max_retries=5, delay_seconds=3):
@@ -26,7 +25,11 @@ def wrapper(self, *args, **kwargs):
2625
return func(self, *args, **kwargs)
2726
except ClientRequestException as e:
2827
last_exception = e
29-
if e.response.status_code == 403:
28+
if e.response.status_code == 429:
29+
print(f"Erro 429 (Muitas solicitações) detectado. Aguardando 60 segundos...")
30+
time.sleep(60)
31+
continue
32+
elif e.response.status_code == 403:
3033
print("Erro 403 (Proibido) detectado. Tentando relogar...")
3134
if not (self.username and self.password):
3235
print("Credenciais não disponíveis para relogin. Abortando.")
@@ -35,7 +38,6 @@ def wrapper(self, *args, **kwargs):
3538
if self.login(self.username, self.password):
3639
print("Relogin bem-sucedido. Tentando a operação novamente.")
3740
try:
38-
# Tenta a operação mais uma vez após o relogin
3941
return func(self, *args, **kwargs)
4042
except ClientRequestException as e2:
4143
print(f"A operação falhou mesmo após o relogin: {e2}")

0 commit comments

Comments
 (0)