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 | |
George Keishing | e635ddc | 2022-12-08 07:38:02 -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( |
George Keishing | e635ddc | 2022-12-08 07:38:02 -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 " |
George Keishing | e635ddc | 2022-12-08 07:38:02 -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, |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 22 | prefix_chars='-+') |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 23 | parser.add_argument( |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 24 | '--host', |
| 25 | default='', |
| 26 | help='The host name or IP of the system to subscribe to.') |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 27 | parser.add_argument( |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 28 | '--username', |
| 29 | default='root', |
| 30 | help='The username for the host system.') |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 31 | parser.add_argument( |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 32 | '--password', |
| 33 | default='', |
| 34 | help='The password for the host system.') |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 35 | parser.add_argument( |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 36 | '--dbus_path', |
| 37 | default='', |
| 38 | help='The path to be monitored (e.g. "/xyz/openbmc_project/sensors").') |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 39 | parser.add_argument( |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 40 | '--enable_trace', |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 41 | choices=[0, 1], |
| 42 | default=0, |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 43 | help='Indicates that trace needs to be enabled.') |
Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 44 | |
| 45 | |
| 46 | # Populate stock_list with options we want. |
| 47 | stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)] |
| 48 | |
| 49 | |
| 50 | def 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 | |
| 57 | main() |