diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..f854316e --- /dev/null +++ b/setup.py @@ -0,0 +1,13 @@ +from setuptools import setup, find_packages + +setup(name='shotgunEvents', + version='0.1', + description='Shotgun Event daemon', + url='https://github.com/shotgunsoftware/shotgunEvents', + author='Shotgun', + author_email='', + maintainer='', + maintainer_email='', + license='', + package_dir={'shotgunEvents': 'src'}, + packages=['shotgunEvents']) diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/shotgunEventDaemon.py b/src/shotgunEventDaemon.py index 42dbb558..b4f4831c 100755 --- a/src/shotgunEventDaemon.py +++ b/src/shotgunEventDaemon.py @@ -55,7 +55,7 @@ import win32event import servicemanager -import daemonizer +from shotgunEvents import daemonizer import shotgun_api3 as sg from shotgun_api3.lib.sgtimezone import SgTimezone @@ -287,14 +287,14 @@ def __init__(self, configPath): print(self.config.getLogFile()) # Set the engine logger for email output. - self.log = logging.getLogger("engine") - self.setEmailsOnLogger(self.log, True) + self.log = logging.getLogger('engine') + self.setEmailsOnLogger(self.log, self.config.getboolean('emails', 'enabled')) else: # Set the engine logger for file and email output. self.log = logging.getLogger("engine") self.log.config = self.config _setFilePathOnLogger(self.log, self.config.getLogFile()) - self.setEmailsOnLogger(self.log, True) + self.setEmailsOnLogger(self.log, self.config.getboolean('emails', 'enabled')) self.log.setLevel(self.config.getLogLevel()) @@ -748,7 +748,8 @@ 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) + if self._engine.config.getboolean('emails', 'enabled'): + self._engine.setEmailsOnLogger(self.logger, True) self.logger.setLevel(self._engine.config.getLogLevel()) if self._engine.config.getLogMode() == 1: _setFilePathOnLogger( @@ -1273,7 +1274,7 @@ class WindowsService(win32serviceutil.ServiceFramework): def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) - self._engine = Engine(_getConfigPath()) + self._engine = Engine(args[0]) def SvcStop(self): """ @@ -1305,12 +1306,10 @@ class LinuxDaemon(daemonizer.Daemon): """ Linux Daemon wrapper or wrapper used for foreground operation on Windows """ + def __init__(self, config_path): + self._engine = Engine(config_path) - def __init__(self): - self._engine = Engine(_getConfigPath()) - super(LinuxDaemon, self).__init__( - "shotgunEvent", self._engine.config.getEnginePIDFile() - ) + super(LinuxDaemon, self).__init__('shotgunEvent', self._engine.config.getEnginePIDFile()) def start(self, daemonize=True): if not daemonize: @@ -1346,12 +1345,17 @@ def main(): if len(sys.argv) > 1: action = sys.argv[1] - if sys.platform == "win32" and action != "foreground": - win32serviceutil.HandleCommandLine(WindowsService) + if len(sys.argv) > 2: + config_path = sys.argv[2] + else: + config_path = _getConfigPath() + + if sys.platform == 'win32' and action != 'foreground': + win32serviceutil.HandleCommandLine(WindowsService, argv=[config_path]) return 0 if action: - daemon = LinuxDaemon() + daemon = LinuxDaemon(config_path) # Find the function to call on the daemon and call it func = getattr(daemon, action, None)