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): class Scripts(object):
def __init__(self, **kwargs): 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): def conf(self, options):
return cherrypy.config['config'].get('Scripts', options) return cherrypy.config['config'].get('Scripts', options)
@ -1807,7 +1807,7 @@ class Scripts(object):
return scripts 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: Args:
subject(string, optional): Head text, 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" % 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)) (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: if not plexpy.CONFIG.SCRIPTS_FOLDER:
return return
@ -1879,6 +1882,8 @@ class Scripts(object):
prefix = 'perl' prefix = 'perl'
elif ext == '.rb': elif ext == '.rb':
prefix = 'ruby' prefix = 'ruby'
elif ext == '.ps1':
prefix = 'powershell -executionPolicy bypass -file'
else: else:
prefix = '' prefix = ''
@ -1886,7 +1891,10 @@ class Scripts(object):
script = script.encode(plexpy.SYS_ENCODING, 'ignore') script = script.encode(plexpy.SYS_ENCODING, 'ignore')
if prefix: if prefix:
script = [prefix, script] if ext == '.ps1':
script = prefix.split() + [script]
else:
script = [prefix, script]
else: else:
script = [script] script = [script]