Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/shotgunEventDaemon.conf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ fetch_interval = 5
max_event_batch_size = 500


[proxy]
# Proxy settings for reaching the shotgun server.
# http_proxy: $HTTP_PROXY$

[shotgun]
# Shotgun connection options for the daemon

Expand Down
32 changes: 19 additions & 13 deletions src/shotgunEventDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
import ConfigParser
import datetime
import imp
import logging
import logging.handlers
import os
import pprint
import socket
import sys
import time
import types
import traceback

from distutils.version import StrictVersion
Expand Down Expand Up @@ -137,6 +135,11 @@ def __init__(self, path):
def getShotgunURL(self):
return self.get('shotgun', 'server')

def getShotgunProxy(self):
if self.has_option('proxy', 'http_proxy'):
return self.get('proxy', 'http_proxy')
return None

def getEngineScriptName(self):
return self.get('shotgun', 'name')

Expand All @@ -153,7 +156,9 @@ def getPluginPaths(self):
return [s.strip() for s in self.get('plugins', 'paths').split(',')]

def getSMTPServer(self):
return self.get('emails', 'server')
if self.has_option('emails', 'server'):
return self.get('emails', 'server')
return None

def getSMTPPort(self):
if self.has_option('emails', 'port'):
Expand Down Expand Up @@ -237,7 +242,8 @@ def __init__(self, configPath):
self._sg = sg.Shotgun(
self.config.getShotgunURL(),
self.config.getEngineScriptName(),
self.config.getEngineScriptKey()
self.config.getEngineScriptKey(),
http_proxy=self.config.getShotgunProxy()
)
self._max_conn_retries = self.config.getint('daemon', 'max_conn_retries')
self._conn_retry_sleep = self.config.getint('daemon', 'conn_retry_sleep')
Expand Down Expand Up @@ -372,7 +378,7 @@ def _loadEventIdData(self):
order = [{'column':'id', 'direction':'desc'}]
try:
result = self._sg.find_one("EventLogEntry", filters=[], fields=['id'], order=order)
except (sg.ProtocolError, sg.ResponseError, socket.err), err:
except (sg.ProtocolError, sg.ResponseError, socket.error), err:
conn_attempts = self._checkConnectionAttempts(conn_attempts, str(err))
except Exception, err:
msg = "Unknown error: %s" % str(err)
Expand Down Expand Up @@ -421,7 +427,7 @@ def _mainLoop(self):
# Reload plugins
for collection in self._pluginCollections:
collection.load()

# Make sure that newly loaded events have proper state.
self._loadEventIdData()

Expand All @@ -446,7 +452,7 @@ def _getNewEvents(self):
filters = [['id', 'greater_than', nextEventId - 1]]
fields = ['id', 'event_type', 'attribute_name', 'meta', 'entity', 'user', 'project', 'session_uuid']
order = [{'column':'id', 'direction':'asc'}]

conn_attempts = 0
while True:
try:
Expand All @@ -463,7 +469,7 @@ def _getNewEvents(self):

def _saveEventIdData(self):
"""
Save an event Id to persistant storage.
Save an event Id to persistent storage.

Next time the engine is started it will try to read the event id from
this location to know at which event it should start processing.
Expand Down Expand Up @@ -580,9 +586,9 @@ class Plugin(object):
The plugin class represents a file on disk which contains one or more
callbacks.
"""
def __init__(self, engine, path):
def __init__(self, engine, path, emails=True):
"""
@param engine: The engine that instanciated this plugin.
@param engine: The engine that instantiated this plugin.
@type engine: L{Engine}
@param path: The path of the plugin file to load.
@type path: I{str}
Expand All @@ -605,7 +611,7 @@ def __init__(self, engine, path):
# Setup the plugin's logger
self.logger = logging.getLogger('plugin.' + self.getName())
self.logger.config = self._engine.config
self._engine.setEmailsOnLogger(self.logger, True)
self._engine.setEmailsOnLogger(self.logger, emails)
self.logger.setLevel(self._engine.config.getLogLevel())
if self._engine.config.getLogMode() == 1:
_setFilePathOnLogger(self.logger, self._engine.config.getLogFile('plugin.' + self.getName()))
Expand Down Expand Up @@ -714,7 +720,7 @@ def registerCallback(self, sgScriptName, sgScriptKey, callback, matchEvents=None
Register a callback in the plugin.
"""
global sg
sgConnection = sg.Shotgun(self._engine.config.getShotgunURL(), sgScriptName, sgScriptKey)
sgConnection = sg.Shotgun(self._engine.config.getShotgunURL(), sgScriptName, sgScriptKey, http_proxy=self._engine.config.getShotgunProxy())
self._callbacks.append(Callback(callback, self, self._engine, sgConnection, matchEvents, args, stopOnError))

def process(self, event):
Expand Down Expand Up @@ -818,7 +824,7 @@ def __init__(self, callback, plugin, engine, shotgun, matchEvents=None, args=Non
@type logger: I{logging.Logger}
@param matchEvents: The event filter to match events against before invoking callback.
@type matchEvents: dict
@param args: Any datastructure you would like to be passed to your
@param args: Any data-structure you would like to be passed to your
callback function. Defaults to None.
@type args: Any object.

Expand Down