1#!/usr/bin/env python3
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="-+",
23)
24parser.add_argument(
25    "--host",
26    default="",
27    help="The host name or IP of the system to subscribe to.",
28)
29parser.add_argument(
30    "--username", default="root", help="The username for the host system."
31)
32parser.add_argument(
33    "--password", default="", help="The password for the host system."
34)
35parser.add_argument(
36    "--dbus_path",
37    default="",
38    help='The path to be monitored (e.g. "/xyz/openbmc_project/sensors").',
39)
40parser.add_argument(
41    "--enable_trace",
42    choices=[0, 1],
43    default=0,
44    help="Indicates that trace needs to be enabled.",
45)
46
47
48# Populate stock_list with options we want.
49stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)]
50
51
52def main():
53    gen_setup()
54    my_event = event_notification(host, username, password)
55    event_notifications = my_event.subscribe(dbus_path, enable_trace)
56    print_var(event_notifications, fmt=[no_header(), strip_brackets()])
57
58
59main()
60