Couldn't test Synoindex. fix #814

This commit is contained in:
Ruud
2012-09-16 20:20:47 +02:00
parent ce3efd3a3c
commit 8fb24bb101
@@ -1,4 +1,5 @@
from couchpotato.core.event import addEvent from couchpotato.core.event import addEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.notifications.base import Notification from couchpotato.core.notifications.base import Notification
import subprocess import subprocess
@@ -9,13 +10,14 @@ log = CPLog(__name__)
class Synoindex(Notification): class Synoindex(Notification):
def __init__(self): def __init__(self):
super(Synoindex, self).__init__()
addEvent('renamer.after', self.addToLibrary) addEvent('renamer.after', self.addToLibrary)
def addToLibrary(self, group = {}): def addToLibrary(self, group = {}):
if self.isDisabled(): return if self.isDisabled(): return
command = ['/usr/syno/bin/synoindex', '-A', group.get('destination_dir')] command = ['/usr/syno/bin/synoindex', '-A', group.get('destination_dir', '')]
log.info(u'Executing synoindex command: %s ', command) log.info('Executing synoindex command: %s ', command)
try: try:
p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) p = subprocess.Popen(command, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
out = p.communicate() out = p.communicate()
@@ -26,3 +28,7 @@ class Synoindex(Notification):
return False return False
return True return True
def test(self):
success = self.addToLibrary()
return jsonified({'success': success})