I would like to automate a script execution on a subprocess, so I am using subprocess lib to create the thread and schedule lib to schedule it.
I would like to verify that the script remotely executed, is working without problems.
The code I was trying does not print any error when the script returns 1 (error) or when the script_file is absent. (And if I am not mistaken, adding the exception wrapper kills the subprocess and do its job )
import os
import sys
import subprocess
import multiprocessing
import schedule
import time
import functools
class MyClass:
        def catch_exceptions(job_func):
                @functools.wraps(job_func)
                def wrapper(*args, **kwargs):
                        try:
                                job_func(*args, **kwargs)
                        except:
                                import traceback
                                print ("Error")
                                print(traceback.format_exc())
                return wrapper
        @catch_exceptions
        def run(self, user, host, command):
                subprocess.call(["ssh", user + "@" + host, command])
        def sched(user, host, script_path):          
               schedule.every(0.01).minutes.do(self.run, user, host, script_path)
All suggestions are welcome, using wrappers is not the goal, but any solution to verify the execution of sched method is good also.
 
     
     
    