Exemplo n.º 1
0
    def run_once(cls, timestamp=None, in_seconds=None):
        """Once AFTER timestamp.
        
        Create scheduler child object which executes run() at appointed time
        Creates a thread and is expected to be run in a thread supporting script.
        
        Args:
            Opt Int         timestamp: Unix timestamp
            Opt Int         in_seconds: Added to current timestamp
            Func            callback: Code to run
            
        Returns:
            Bool
        """
        if timestamp is None and in_seconds is None:
            raise TypeError(
                'Define either timestamp or in_seconds with an int value')

        if in_seconds:
            timestamp = time.time() + in_seconds

        obj = cls()
        obj.timestamp = timestamp
        ThreadHandler.create_thread(obj._run_once_callback)

        str_time = datetime.datetime.fromtimestamp(int(timestamp))
        out('Scheduler: Class "{}" tasked with run_once at {}.'.format(
            obj.__class__.__name__, str_time))
        return obj
Exemplo n.º 2
0
    def run_once(cls, timestamp=None, in_seconds=None):
        """Once AFTER timestamp.
        
        Create scheduler child object which executes run() at appointed time
        Creates a thread and is expected to be run in a thread supporting script.
        
        Args:
            Opt Int         timestamp: Unix timestamp
            Opt Int         in_seconds: Added to current timestamp
            Func            callback: Code to run
            
        Returns:
            Bool
        """
        if timestamp is None and in_seconds is None:
            raise TypeError('Define either timestamp or in_seconds with an int value')

        if in_seconds:
            timestamp = time.time() + in_seconds

        obj = cls()
        obj.timestamp = timestamp
        ThreadHandler.create_thread(obj._run_once_callback)

        str_time = datetime.datetime.fromtimestamp(int(timestamp))
        out('Scheduler: Class "{}" tasked with run_once at {}.'.format(obj.__class__.__name__, str_time))
        return obj
Exemplo n.º 3
0
 def run_daily(cls, time_string):
     """Every day after hh:mm:ss
     
     Create scheduler child object which executes run() at appointed time
     Creates a thread and is expected to be run in a thread supporting script.
     
     Args:
         Str     time_string: Syntax hh:mm:ss
         Func    callback: Code to run
         Bool    immediately: Run callback immediately after creation
         
     Returns:
         Bool
     """
     obj = cls()
     obj.time_string = time_string
     ThreadHandler.create_thread(obj._run_daily_callback)
     out('Scheduler: Class "{}" tasked with run_daily at {}.'.format(obj.__class__.__name__, time_string))
     return obj
Exemplo n.º 4
0
 def run_daily(cls, time_string):
     """Every day after hh:mm:ss
     
     Create scheduler child object which executes run() at appointed time
     Creates a thread and is expected to be run in a thread supporting script.
     
     Args:
         Str     time_string: Syntax hh:mm:ss
         Func    callback: Code to run
         Bool    immediately: Run callback immediately after creation
         
     Returns:
         Bool
     """
     obj = cls()
     obj.time_string = time_string
     ThreadHandler.create_thread(obj._run_daily_callback)
     out('Scheduler: Class "{}" tasked with run_daily at {}.'.format(
         obj.__class__.__name__, time_string))
     return obj
Exemplo n.º 5
0
    def run_interval(cls, seconds, immediately=False):
        """Every X seconds
        
        Create scheduler child object which executes run() at appointed time
        Creates a thread and is expected to be run in a thread supporting script.
        
        Args:
            Int     seconds: Seconds between each run
            Func    callback: Code to run
            Bool    immediately: Run callback immediately after creation
            
        Returns:
            Bool
        """
        obj = cls()
        obj.interval = seconds
        obj.immediately = immediately

        out('Scheduler: Class "{}" tasked with run_interval {} seconds.'.format(obj.__class__.__name__, seconds))
        ThreadHandler.create_thread(obj._run_interval_callback)
        return obj
Exemplo n.º 6
0
    def run_interval(cls, seconds, immediately=False):
        """Every X seconds
        
        Create scheduler child object which executes run() at appointed time
        Creates a thread and is expected to be run in a thread supporting script.
        
        Args:
            Int     seconds: Seconds between each run
            Func    callback: Code to run
            Bool    immediately: Run callback immediately after creation
            
        Returns:
            Bool
        """
        obj = cls()
        obj.interval = seconds
        obj.immediately = immediately

        out('Scheduler: Class "{}" tasked with run_interval {} seconds.'.
            format(obj.__class__.__name__, seconds))
        ThreadHandler.create_thread(obj._run_interval_callback)
        return obj
Exemplo n.º 7
0
 def __init__(self, master):
     Frame.__init__(self,master)
     self.pack(fill=BOTH, expand=1)
     self.create_widgets()
     ThreadHandler.create_thread(GuiTasks.loop)