1#!/usr/bin/env python
2
3r"""
4See help text for details.
5"""
6
7import sys
8
9save_dir_path = sys.path.pop(0)
10
11modules = ['gen_arg', 'gen_print', 'gen_valid', 'event_notification']
12for module in modules:
13    exec("from " + module + " import *")
14
15sys.path.insert(0, save_dir_path)
16
17parser = argparse.ArgumentParser(
18    usage='%(prog)s [OPTIONS]',
19    description="%(prog)s will subscribe and receive event notifications when "
20                + "properties change for the given dbus path.",
21    formatter_class=argparse.ArgumentDefaultsHelpFormatter,
22    prefix_chars='-+')
23parser.add_argument(
24    '--host',
25    default='',
26    help='The host name or IP of the system to subscribe to.')
27parser.add_argument(
28    '--username',
29    default='root',
30    help='The username for the host system.')
31parser.add_argument(
32    '--password',
33    default='',
34    help='The password for the host system.')
35parser.add_argument(
36    '--dbus_path',
37    default='',
38    help='The path to be monitored (e.g. "/xyz/openbmc_project/sensors").')
39parser.add_argument(
40    '--enable_trace',
41    choices=[0, 1],
42    default=0,
43    help='Indicates that trace needs to be enabled.')
44
45
46# Populate stock_list with options we want.
47stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)]
48
49
50def main():
51    gen_setup()
52    my_event = event_notification(host, username, password)
53    event_notifications = my_event.subscribe(dbus_path, enable_trace)
54    print_var(event_notifications, fmt=[no_header(), strip_brackets()])
55
56
57main()
58