1 # Copyright (C) 2015 - Philippe Proulx <pproulx@efficios.com>
2 # Copyright (C) 2014 - David Goulet <dgoulet@efficios.com>
4 # This library is free software; you can redistribute it and/or modify it under
5 # the terms of the GNU Lesser General Public License as published by the Free
6 # Software Foundation; version 2.1 of the License.
8 # This library is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with this library; if not, write to the Free Software Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 from __future__
import unicode_literals
, print_function
26 print(msg
, file=sys
.stderr
)
32 except (ImportError) as e
:
33 _perror('lttngust package not found: {}'.format(e
))
37 ev1
= logging
.getLogger('python-ev-test1');
38 ev2
= logging
.getLogger('python-ev-test2');
42 parser
= argparse
.ArgumentParser()
43 parser
.add_argument('-n', '--nr-iter', required
=True)
44 parser
.add_argument('-s', '--wait', required
=True)
45 parser
.add_argument('-d', '--fire-debug-event', action
="store_true")
46 parser
.add_argument('-e', '--fire-second-event', action
="store_true")
47 parser
.add_argument('-r', '--ready-file')
48 parser
.add_argument('-g', '--go-file')
49 args
= parser
.parse_args()
51 nr_iter
= int(args
.nr_iter
)
52 wait_time
= float(args
.wait
)
53 fire_debug_ev
= args
.fire_debug_event
54 fire_second_ev
= args
.fire_second_event
56 ready_file
= args
.ready_file
57 go_file
= args
.go_file
59 if ready_file
is not None and os
.path
.exists(ready_file
):
60 raise ValueError('Ready file already exist')
62 if go_file
is not None and os
.path
.exists(go_file
):
63 raise ValueError('Go file already exist. Review synchronization')
65 if (ready_file
is None) != (go_file
is None):
66 raise ValueError('--go-file and --ready-file need each others, review'
70 # Inform that we are ready, if necessary
71 if ready_file
is not None:
72 open(ready_file
, 'a').close()
74 # Wait for go, if necessary
75 while go_file
is not None and not os
.path
.exists(go_file
):
78 for i
in range(nr_iter
):
79 ev1
.info('{} fired [INFO]'.format(ev1
.name
))
82 ev1
.debug('{} fired [DEBUG]'.format(ev1
.name
))
87 ev2
.info('{} fired [INFO]'.format(ev2
.name
))
89 if ready_file
is not None:
93 print("Unexpected error on ready file unlink:", sys
.exc_info()[0])
97 if __name__
== '__main__':
This page took 0.033885 seconds and 4 git commands to generate.