Coverage for pyquickhelper/cli/script_exec.py: 12%

8 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-03 02:21 +0200

1""" 

2@file 

3@brief Repeat execution. 

4""" 

5 

6 

7def repeat_script(script, every_second=20, stop_after_second=-1, 

8 outfile='out.log', errfile='err.log', 

9 exc=True, verbose=1, fLOG=print): 

10 """ 

11 Runs a python script on a regular basis. The function 

12 is not multithreaded, it returns when all execution 

13 are done. 

14 

15 :param script: script to run 

16 :param every_second: every second 

17 :param stop_after_second: stop after a given time or never if -1 

18 :param outfile: file which receives the standard output 

19 :param errfile: file which receives the standard error 

20 :param exc: True to stop if an exception is raised, False to continue 

21 :param verbose: prints out every execution 

22 :param fLOG: logging function 

23 

24 .. cmdref:: 

25 :title: Repeat script execution every n seconds 

26 :cmd: -m pyquickhelper repeat_script --help 

27 

28 The command line runs the execution a script 

29 on a regular basis. 

30 """ 

31 from ..loghelper.time_helper import repeat_script_execution 

32 

33 every_second = int(every_second) 

34 stop_after_second = int(stop_after_second) 

35 if stop_after_second == -1: 

36 stop_after_second = None 

37 exc = exc in ('1', 1, 'True', 'true', True) 

38 

39 repeat_script_execution(script, every_second=every_second, 

40 stop_after_second=stop_after_second, 

41 outfile=outfile, errfile=errfile, 

42 verbose=1, fLOG=fLOG, exc=exc)