Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing config path as argument, create setup.py #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from setuptools import setup, find_packages
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'setuptools.find_packages' imported but unused


setup(name='shotgunEvents',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black would make changes.

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'])
Empty file added src/__init__.py
Empty file.
32 changes: 18 additions & 14 deletions src/shotgunEventDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down