forked from rapidpro/rapidpro
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use debug logging for channel types errors, D3 and WA
- Loading branch information
Showing
5 changed files
with
56 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import logging | ||
|
||
import requests | ||
|
||
from django.utils import timezone | ||
|
||
from temba.request_logs.models import HTTPLog | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def update_api_version(channel): | ||
start = timezone.now() | ||
try: | ||
response = channel.type.check_health(channel) | ||
api_status = response.json() | ||
version = api_status["meta"]["version"] | ||
if not version.startswith("v"): | ||
version = "v" + version | ||
channel.config.update(version=version) | ||
channel.save(update_fields=("config",)) | ||
except requests.RequestException as e: | ||
HTTPLog.from_exception(HTTPLog.WHATSAPP_CHECK_HEALTH, e, start, channel=channel) | ||
except Exception as e: # pragma: no cover | ||
logger.error(f"Error retrieving WhatsApp API version: {str(e)}", exc_info=True) | ||
response = channel.type.check_health(channel) | ||
if not response: | ||
logger.debug("Error retrieving WhatsApp API version: Failed to check health") | ||
return | ||
api_status = response.json() | ||
version = api_status["meta"]["version"] | ||
if not version.startswith("v"): | ||
version = "v" + version | ||
channel.config.update(version=version) | ||
channel.save(update_fields=("config",)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters