Add option to return a Non instantiated class

This commit is contained in:
twangboy 2017-02-15 10:01:22 -07:00
parent 315b0cc105
commit e67387deb7
2 changed files with 8 additions and 3 deletions

View file

@ -15,7 +15,7 @@ import win32service
import winerror
class MinionService(service):
class MinionService(service(False)):
def start(self):
self.runflag = True

View file

@ -30,10 +30,15 @@ def __virtual__():
return 'winservice'
def service():
def service(instantiated=True):
'''
Helper function to return an instance of the ServiceFramework class
Args:
instantiated (bool): True to return an instantiated object, False to
return the object definition. Use False if inherited by another
class. Default is True.
Returns:
class: An instance of the ServiceFramework class
'''
@ -87,7 +92,7 @@ def service():
def stop(self):
pass
return Service()
return Service() if instantiated else Service
def instart(cls, name, display_name=None, stay_alive=True):