George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 2 | |
| 3 | r""" |
| 4 | See help text for details. |
| 5 | """ |
| 6 | |
| 7 | import sys |
| 8 | |
| 9 | save_dir_path = sys.path.pop(0) |
| 10 | |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 11 | modules = ["gen_arg", "gen_print", "gen_valid", "event_notification"] |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 12 | for module in modules: |
| 13 | exec("from " + module + " import *") |
| 14 | |
| 15 | sys.path.insert(0, save_dir_path) |
| 16 | |
| 17 | parser = argparse.ArgumentParser( |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 18 | usage="%(prog)s [OPTIONS]", |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 19 | description="%(prog)s will subscribe and receive event notifications when " |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 20 | + "properties change for the given dbus path.", |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 21 | formatter_class=argparse.ArgumentDefaultsHelpFormatter, |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 22 | prefix_chars="-+", |
| 23 | ) |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 24 | parser.add_argument( |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 25 | "--host", |
| 26 | default="", |
| 27 | help="The host name or IP of the system to subscribe to.", |
| 28 | ) |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 29 | parser.add_argument( |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 30 | "--username", default="root", help="The username for the host system." |
| 31 | ) |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 32 | parser.add_argument( |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 33 | "--password", default="", help="The password for the host system." |
| 34 | ) |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 35 | parser.add_argument( |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 36 | "--dbus_path", |
| 37 | default="", |
| 38 | help='The path to be monitored (e.g. "/xyz/openbmc_project/sensors").', |
| 39 | ) |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 40 | parser.add_argument( |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 41 | "--enable_trace", |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 42 | choices=[0, 1], |
| 43 | default=0, |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 44 | help="Indicates that trace needs to be enabled.", |
| 45 | ) |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 46 | |
| 47 | |
| 48 | # Populate stock_list with options we want. |
| 49 | stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)] |
| 50 | |
| 51 | |
| 52 | def 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 | |
| 59 | main() |