1 # Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
2 # Copyright (C) 2014 David Goulet <dgoulet@efficios.com>
4 # SPDX-License-Identifier: LGPL-2.1-only
6 from __future__
import unicode_literals
, print_function
15 print(msg
, file=sys
.stderr
)
21 except ImportError as e
:
22 _perror("lttngust package not found: {}".format(e
))
26 ev1
= logging
.getLogger("python-ev-test1")
27 ev2
= logging
.getLogger("python-ev-test2")
31 parser
= argparse
.ArgumentParser()
32 parser
.add_argument("-n", "--nr-iter", required
=True)
33 parser
.add_argument("-s", "--wait", required
=True)
34 parser
.add_argument("-d", "--fire-debug-event", action
="store_true")
35 parser
.add_argument("-e", "--fire-second-event", action
="store_true")
36 parser
.add_argument("-r", "--ready-file")
37 parser
.add_argument("-g", "--go-file")
38 args
= parser
.parse_args()
40 nr_iter
= int(args
.nr_iter
)
41 wait_time
= float(args
.wait
)
42 fire_debug_ev
= args
.fire_debug_event
43 fire_second_ev
= args
.fire_second_event
45 ready_file
= args
.ready_file
46 go_file
= args
.go_file
48 if ready_file
is not None and os
.path
.exists(ready_file
):
49 raise ValueError("Ready file already exist")
51 if go_file
is not None and os
.path
.exists(go_file
):
52 raise ValueError("Go file already exist. Review synchronization")
54 if (ready_file
is None) != (go_file
is None):
56 "--go-file and --ready-file need each others, review" "synchronization"
59 # Inform that we are ready, if necessary
60 if ready_file
is not None:
61 open(ready_file
, "a").close()
63 # Wait for go, if necessary
64 while go_file
is not None and not os
.path
.exists(go_file
):
67 for i
in range(nr_iter
):
68 ev1
.info("{} fired [INFO]".format(ev1
.name
))
71 ev1
.debug("{} fired [DEBUG]".format(ev1
.name
))
76 ev2
.info("{} fired [INFO]".format(ev2
.name
))
78 if ready_file
is not None:
82 print("Unexpected error on ready file unlink:", sys
.exc_info()[0])
86 if __name__
== "__main__":
This page took 0.030554 seconds and 4 git commands to generate.