Anusha Dathatri | 1cd34b5 | 2019-08-13 04:43:12 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | See help text for details. |
| 5 | """ |
| 6 | |
| 7 | import sys |
| 8 | |
| 9 | save_dir_path = sys.path.pop(0) |
| 10 | |
| 11 | modules = ['gen_arg', 'gen_print', 'gen_valid', 'event_notification'] |
| 12 | for module in modules: |
| 13 | exec("from " + module + " import *") |
| 14 | |
| 15 | sys.path.insert(0, save_dir_path) |
| 16 | |
| 17 | parser = 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 | parser.add_argument( |
| 24 | '--host', |
| 25 | default='', |
| 26 | help='The host name or IP of the system to subscribe to.') |
| 27 | parser.add_argument( |
| 28 | '--username', |
| 29 | default='root', |
| 30 | help='The username for the host system.') |
| 31 | parser.add_argument( |
| 32 | '--password', |
| 33 | default='', |
| 34 | help='The password for the host system.') |
| 35 | parser.add_argument( |
| 36 | '--dbus_path', |
| 37 | default='', |
| 38 | help='The path to be monitored (e.g. "/xyz/openbmc_project/sensors").') |
| 39 | parser.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. |
| 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() |