diff --git a/docs/cookbook/usage_tips.rst b/docs/cookbook/usage_tips.rst index 5d1a7bc1f..128f417ea 100644 --- a/docs/cookbook/usage_tips.rst +++ b/docs/cookbook/usage_tips.rst @@ -236,26 +236,38 @@ automatically set whenever an entity is created or updated. Logging Messages from the API ***************************** -The API uses standard python logging but does not define a handler. +The library uses the standard Python logging module under the logger name +``shotgun_api3``. Developers are free to configure logging handlers as they see +fit in their applications. To see the logging output in stdout, define a streamhandler in your script:: import logging - import shotgun_api3 as shotgun - logging.basicConfig(level=logging.DEBUG) + logging.basicConfig() + + import shotgun_api3 + + sg_log = logging.getLogger("shotgun_api3") + sg_log.setLevel(logging.DEBUG) + To write logging output from the Flow Production Tracking API to a file, define a file handler in your script:: import logging - import shotgun_api3 as shotgun - logging.basicConfig(level=logging.DEBUG, filename='/path/to/your/log') + logging.basicConfig(filename="/path/to/your/log") + + import shotgun_api3 + + sg_log = logging.getLogger("shotgun_api3") + sg_log.setLevel(logging.DEBUG) + To suppress the logging output from the API in a script which uses logging, set the level of the Flow Production Tracking logger to a higher level:: import logging import shotgun_api3 as shotgun - sg_log = logging.getLogger('shotgun_api3') + sg_log = logging.getLogger("shotgun_api3") sg_log.setLevel(logging.ERROR) ************* diff --git a/shotgun_api3/shotgun.py b/shotgun_api3/shotgun.py index 0c0c9cd5c..2e933fd53 100644 --- a/shotgun_api3/shotgun.py +++ b/shotgun_api3/shotgun.py @@ -406,7 +406,8 @@ def __init__(self, sg: "Shotgun"): # In the case that the environment variable is already set, setting the # property on the config will override it. self.rpc_attempt_interval = 3000 - # From http://docs.python.org/2.6/library/httplib.html: + + # From https://docs.python.org/3.9/library/http.client.html: # If the optional timeout parameter is given, blocking operations # (like connection attempts) will timeout after that many seconds # (if it is not given, the global default timeout setting is used) @@ -3981,12 +3982,7 @@ def _make_upload_request( Open the given request object, return the response, raises URLError on protocol errors. """ - try: - result = opener.open(request) - - except urllib.error.HTTPError: - raise - return result + return opener.open(request) def _parse_http_status(self, status: tuple) -> None: """ @@ -4480,7 +4476,7 @@ def _upload_data_to_storage( :param str content_type: Content type of the data stream. :param int size: Number of bytes in the data stream. :param str storage_url: Target URL for the uploaded file. - :returns: upload url. + :returns: etag of the uploaded file (hash of the file content). :rtype: str """