diff --git a/mopidy_iris/system.py b/mopidy_iris/system.py index 0b07128b..2730034d 100755 --- a/mopidy_iris/system.py +++ b/mopidy_iris/system.py @@ -19,7 +19,7 @@ class IrisSystemThread(Thread): logger.info("Running system action: "+self.action) try: - self.check_system_access() + self.can_run() except Exception, e: logger.error(e) @@ -30,10 +30,10 @@ class IrisSystemThread(Thread): if self.callback: self.callback(False, error) - + return # Run the actual task (this is the process-blocking instruction) - output = subprocess.check_output(["sudo "+self.path+"/system.sh "+self.action], shell=True) + output = subprocess.check_output(["sudo -n "+self.path+"/system.sh "+self.action], shell=True) # And then, when complete, return to our callback if self.callback: @@ -48,15 +48,13 @@ class IrisSystemThread(Thread): # # @return boolean or exception ## - def check_system_access(self, *args, **kwargs): + def can_run(self, *args, **kwargs): # Attempt an empty call to our system file - process = subprocess.Popen("sudo -n "+self.path+"/system.sh", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - result, error = process.communicate() - exitCode = process.wait() - - # Some kind of failure, so we can't run any commands this way - if exitCode > 0: - raise Exception("Password-less access to "+self.path+"/system.sh was refused. Check your /etc/sudoers file.") - else: + # If this fails, we can't run any commands this way + try: + subprocess.check_output("sudo -n "+self.path+"/system.sh", stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) return True + except Exception, e: + raise Exception("Password-less access to "+self.path+"/system.sh was refused. Check your /etc/sudoers file.") + return False diff --git a/mopidy_iris/system.sh b/mopidy_iris/system.sh index c882326f..35c6e4f3 100755 --- a/mopidy_iris/system.sh +++ b/mopidy_iris/system.sh @@ -17,10 +17,13 @@ elif [[ $1 = "local_scan" ]]; then elif [[ $1 = "test" ]]; then - sleep 10 + sleep 3 - TEST="$(echo 'Hello, this is your bash speaking. I was sleeping for 10 seconds.')" + TEST="$(echo 'Hello, this is your bash speaking. I was sleeping for 3 seconds.')" echo -e "${TEST}" + +else; + echo -e "Unsupported system task" fi exit 0 \ No newline at end of file diff --git a/src/js/services/pusher/middleware.js b/src/js/services/pusher/middleware.js index d323953a..25c3b918 100755 --- a/src/js/services/pusher/middleware.js +++ b/src/js/services/pusher/middleware.js @@ -157,7 +157,7 @@ const PusherMiddleware = (function(){ break; case 'test_error': store.dispatch(uiActions.processFinished('test')); - store.dispatch(uiActions.createNotification({type: 'bad', content: 'Test failed'})); + store.dispatch(uiActions.createNotification({type: 'bad', content: message.params.message, description: message.params.description})); break; }