add support for powershell

This commit is contained in:
Hellowlol 2016-01-30 23:09:48 +01:00
parent 4d156a8911
commit b2292e98c1

View file

@ -1777,7 +1777,7 @@ class SLACK(object):
class Scripts(object):
def __init__(self, **kwargs):
self.script_exts = ('.bat', '.cmd', '.exe', '.php', '.pl', '.py', '.pyw', '.rb', '.sh')
self.script_exts = ('.bat', '.cmd', '.exe', '.php', '.pl', '.py', '.pyw', '.rb', '.sh', '.ps1')
def conf(self, options):
return cherrypy.config['config'].get('Scripts', options)
@ -1807,7 +1807,7 @@ class Scripts(object):
return scripts
def notify(self, subject='', message='', notify_action='', script_args=[], *args, **kwargs):
def notify(self, subject='', message='', notify_action='', script_args=None, *args, **kwargs):
"""
Args:
subject(string, optional): Head text,
@ -1818,6 +1818,9 @@ class Scripts(object):
logger.debug(u"PlexPy Notifiers :: Trying to run notify script, action: %s, arguments: %s" %
(notify_action if notify_action else None, script_args if script_args else None))
if script_args is None:
script_args = []
if not plexpy.CONFIG.SCRIPTS_FOLDER:
return
@ -1879,6 +1882,8 @@ class Scripts(object):
prefix = 'perl'
elif ext == '.rb':
prefix = 'ruby'
elif ext == '.ps1':
prefix = 'powershell -executionPolicy bypass -file'
else:
prefix = ''
@ -1886,7 +1891,10 @@ class Scripts(object):
script = script.encode(plexpy.SYS_ENCODING, 'ignore')
if prefix:
script = [prefix, script]
if ext == '.ps1':
script = prefix.split() + [script]
else:
script = [prefix, script]
else:
script = [script]