Key Error when starting shotgunEventDaemon

Hi I am getting the Key Error when starting shotgunEventDaemon. SGDAEMON_SGJIRA_NAME is exported to environment variable along with others.

INFO:engine:Using Shotgun Python API version 3.2.4
INFO:engine:Loading plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/sg_jira_event_trigger.py
Traceback (most recent call last):
File “shotgunEventDaemon.py”, line 1251, in emit
smtp.connect(self.mailhost, port)
File “/usr/lib/python2.7/smtplib.py”, line 317, in connect
self.sock = self._get_socket(host, port, self.timeout)
File “/usr/lib/python2.7/smtplib.py”, line 292, in _get_socket
return socket.create_connection((host, port), timeout)
File “/usr/lib/python2.7/socket.py”, line 575, in create_connection
raise err
error: [Errno 111] Connection refused
Logged from file shotgunEventDaemon.py, line 868
CRITICAL:engine:Error running register callback function from plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/sg_jira_event_trigger.py.

Traceback (most recent call last):
File “shotgunEventDaemon.py”, line 863, in load
regFunc(Registrar(self))
File “/home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/sg_jira_event_trigger.py”, line 67, in registerCallbacks
os.environ[“SGDAEMON_SGJIRA_NAME”],
File “/usr/lib/python2.7/UserDict.py”, line 40, in getitem
raise KeyError(key)
KeyError: ‘SGDAEMON_SGJIRA_NAME’

INFO:engine:Loading plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/init.py
Traceback (most recent call last):
File “shotgunEventDaemon.py”, line 1251, in emit
smtp.connect(self.mailhost, port)
File “/usr/lib/python2.7/smtplib.py”, line 317, in connect
self.sock = self._get_socket(host, port, self.timeout)
File “/usr/lib/python2.7/smtplib.py”, line 292, in _get_socket
return socket.create_connection((host, port), timeout)
File “/usr/lib/python2.7/socket.py”, line 575, in create_connection
raise err
error: [Errno 111] Connection refused
Logged from file shotgunEventDaemon.py, line 873
CRITICAL:engine:Did not find a registerCallbacks function in plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/init.py.

2 Likes

It’s hard to say without seeing the code, but possibly the Connection refused error causes the other one? i.e. it throws and some code is not reached.

How do you export the environment variables?

2 Likes

I didnt touch anything in the sg_jira_trigger.py. It is importing as below:

reg.registerCallback(
os.environ[“SGDAEMON_SGJIRA_NAME”],
os.environ[“SGDAEMON_SGJIRA_KEY”],
process_event,
event_filter,
dispatch_routes,
stopOnError=False,
)

1 Like

Hey mbk,

looks like your mail host in the daemon conf might not be set up properly. Maybe check around line 100 of shotgunEventDaemon.conf and see if everything’s the way it should be?

2 Likes

I configured the smtp in the settings.py file and also enable it in Gmail settings. Still getting the error. Though this time there is No connection refused error

INFO:engine:Using Shotgun Python API version 3.2.4
INFO:engine:Loading plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/sg_jira_event_trigger.py
CRITICAL:engine:Error running register callback function from plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/sg_jira_event_trigger.py.

Traceback (most recent call last):
File “shotgunEventDaemon.py”, line 863, in load
regFunc(Registrar(self))
File “/home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/sg_jira_event_trigger.py”, line 67, in registerCallbacks
os.environ[‘SGDAEMON_SGJIRA_NAME’],
File “/usr/lib/python2.7/UserDict.py”, line 40, in getitem
raise KeyError(key)
KeyError: ‘SGDAEMON_SGJIRA_NAME’

INFO:engine:Loading plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/init.py
CRITICAL:engine:Did not find a registerCallbacks function in plugin at /home/tsg/Documents/SG_Jira/sg-jira-bridge/triggers/init.py.

1 Like

Hm ok, then the variable is really not there.
I advise grepping your code base for environ, see if SGDAEMON_SGJIRA_NAME is set anywhere, or if anything clears the environment…
You should also put a debugger breakpoint at the place the key is obtained (in registerCallbacks), to see what the environment looks like. This could give you more specific clues.

4 Likes