Error running self.parent.shotgun.info() or self.parent.shotgun.find() from context_change() hook

Hi All,

Just wondering if anyone has come across an error similar to the one I’m getting when I call self.parent.shotgun.info() from the context_change() hook?

[Errno 2] No such file or directory
Traceback (most recent call last):
  File "/Volumes/sandbox/tomfw/git/config2/core/hooks/context_change.py", line 153, in post_context_change
    self.update_environment(current_context)
  File "/Volumes/sandbox/tomfw/git/config2/core/hooks/context_change.py", line 204, in update_environment
    project_entity = self.get_sg_entity(context.project)
  File "/Volumes/sandbox/tomfw/git/config2/core/hooks/context_change.py", line 279, in get_sg_entity
    self.logger.debug("self.parent.shotgun.info: {}".format(self.parent.shotgun.info()))
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line 799, in info
    return self._call_rpc("info", None, include_auth_params=False)
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank/authentication/shotgun_wrapper.py", line 63, in _call_rpc
    return super(ShotgunWrapper, self)._call_rpc(*args, **kwargs)
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line 3334, in _call_rpc
    req_headers,
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line 3488, in _make_call
    return self._http_request(verb, path, body, req_headers)
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/shotgun.py", line 3542, in _http_request
    resp, content = conn.request(url, method=verb, body=body, headers=headers)
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/lib/httplib2/python2/__init__.py", line 1925, in request
    conn, authority, uri, request_uri, method, body, headers, redirections, cachekey,
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/lib/httplib2/python2/__init__.py", line 1634, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/lib/httplib2/python2/__init__.py", line 1553, in _conn_request
    conn.connect()
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/lib/httplib2/python2/__init__.py", line 1239, in connect
    self.key_password,
  File "/home/users/tomfw/.shotgun/union/p2160c4370.basic.desktop/cfg/install/core/python/tank_vendor/shotgun_api3/lib/httplib2/python2/__init__.py", line 98, in _ssl_wrap_socket
    context.load_verify_locations(ca_certs)
IOError: [Errno 2] No such file or directory

To be fully clear I don’t really want the shotgun.info()… I’m actually trying to run a shotgun.find() but that is also failing with a similar error… but I’d tied shotgun.info as I thought it might be more “basic” for troubleshooting purposes.

I’ll keep debugging at my end… but if anyone’s encountered this before I’d love to hear from you :slight_smile:

Thanks
Tom

Are you running this from a renderfarm?
Or what kind of environment?

You are running into an issue where your CA certicates are not refreshed.

If you set the following environment variable:

SHOTGUN_API_CACERTS

and point it to this file somewhere on disk:

https://github.com/shotgunsoftware/python-api/blob/master/shotgun_api3/lib/httplib2/python3/cacerts.txt

Then it will work.
If running in an engine or from SG Desktop this should not be needed.
But farm processes do need this.

1 Like

Hey @Ricardo_Musch ,

Thanks for your swift reply!

Turns out your were bang on the money! We have have a custom module for managing our environment variables that runs during the tank_init.py and that was overwriting the SHOTGUN_API_CACERTS env var to a non-existent file path. Now that I’ve updated our system for that so it picks it up in a more dynamic way (and finds a file that I’m distributing with the sgtk config itself) it’s working fine.

Thanks very much for your help!

Tom

1 Like