Skip to content

Commit

Permalink
[FIX] *_online_ponto: log parameters should be a single dict
Browse files Browse the repository at this point in the history
  • Loading branch information
NL66278 committed Apr 4, 2023
1 parent 5c997cd commit 5a9b71c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ def _ponto_pull(self, date_since, date_until):
if is_scheduled:
_logger.debug(
_(
"Ponto obtain statement data for journal {journal}"
" from {date_since} to {date_until}"
"Ponto obtain statement data for journal %(journal)s"
" from %(date_since)s to %(date_until)s"
),
dict(
journal=self.journal_id.name,
date_since=date_since,
date_until=date_until,
),
journal=self.journal_id.name,
date_since=date_since,
date_until=date_until,
)
else:
_logger.debug(
Expand Down
22 changes: 12 additions & 10 deletions account_statement_import_online_ponto/models/ponto_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _login(self, username, password):
"Accept": "application/json",
"Authorization": "Basic {login}".format(login=login),
}
_logger.debug(_("POST request on {url}"), url=url)
_logger.debug(_("POST request on %(url)s"), dict(url=url))
response = requests.post(
url,
params={"grant_type": "client_credentials"},
Expand Down Expand Up @@ -71,7 +71,7 @@ def _get_request_headers(self, access_data):
def _set_access_account(self, access_data, account_number):
"""Set ponto account for bank account in access_data."""
url = PONTO_ENDPOINT + "/accounts"
_logger.debug(_("GET request on {}"), url)
_logger.debug(_("GET request on %(url)s"), dict(url=url))
response = requests.get(
url,
params={"limit": 100},
Expand Down Expand Up @@ -119,8 +119,8 @@ def _get_transactions_from_data(self, data):
transactions = data.get("data", [])
if not transactions:
_logger.debug(
_("No transactions where found in data {}"),
data,
_("No transactions where found in data %(data)s"),
dict(data=data),
)
else:
_logger.debug(
Expand All @@ -133,10 +133,12 @@ def _get_request(self, access_data, url, params):
"""Interact with Ponto to get next page of data."""
headers = self._get_request_headers(access_data)
_logger.debug(
_("GET request to {url} with headers {headers} and params {params}"),
url=url,
headers=headers,
params=params,
_("GET request to %(url)s with headers %(headers)s and params %(params)s"),
dict(
url=url,
headers=headers,
params=params,
),
)
response = requests.get(
url,
Expand All @@ -149,8 +151,8 @@ def _get_request(self, access_data, url, params):
def _get_response_data(self, response):
"""Get response data for GET or POST request."""
_logger.debug(
_("HTTP answer code {response_code} from Ponto"),
response_code=response.status_code,
_("HTTP answer code %(response_code)s from Ponto"),
dict(response_code=response.status_code),
)
if response.status_code not in (200, 201):
raise UserError(
Expand Down

0 comments on commit 5a9b71c

Please sign in to comment.