1#!/usr/bin/env python
2
3r"""
4See help text for details.
5"""
6
7import sys
8
9save_path_0 = sys.path[0]
10del sys.path[0]
11
12from gen_arg import *
13from gen_print import *
14from gen_valid import *
15from openbmc_ffdc_list import *
16
17# Restore sys.path[0].
18sys.path.insert(0, save_path_0)
19
20# Set exit_on_error for gen_valid functions.
21set_exit_on_error(True)
22
23parser = argparse.ArgumentParser(
24    usage='%(prog)s [OPTIONS]',
25    description="%(prog)s will print a colon-delimited list of all valid OBMC FFDC functions.\n\nExample:" +
26    "\n\n\nDump Log:FFDC Generic Report:Get Request FFDC:SEL Log:BMC Specific Files:Sys Inventory Files" +
27    ":Core Files:OS FFDC:Dump Files",
28    formatter_class=argparse.RawDescriptionHelpFormatter,
29    prefix_chars='-+')
30
31# Populate stock_list with options we want.
32stock_list = [("test_mode", 0), ("quiet", 1), ("debug", 0)]
33
34
35def exit_function(signal_number=0,
36                  frame=None):
37    r"""
38    Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).
39    """
40
41    dprint_executing()
42    dprint_var(signal_number)
43
44    qprint_pgm_footer()
45
46
47def signal_handler(signal_number,
48                   frame):
49    r"""
50    Handle signals.  Without a function to catch a SIGTERM or SIGINT, our program would terminate immediately
51    with return code 143 and without calling our exit_function.
52    """
53
54    # Our convention is to set up exit_function with atexit.register() so there is no need to explicitly
55    # call exit_function from here.
56
57    dprint_executing()
58
59    # Calling exit prevents us from returning to the code that was running when we received the signal.
60    exit(0)
61
62
63def validate_parms():
64    r"""
65    Validate program parameters, etc.
66    """
67
68    gen_post_validation(exit_function, signal_handler)
69
70
71def main():
72
73    gen_get_options(parser, stock_list)
74
75    validate_parms()
76
77    qprint_pgm_header()
78
79    my_openbmc_ffdc_list = openbmc_ffdc_list()
80    ffdc_function_list = my_openbmc_ffdc_list.get_ffdc_method_desc('BMC LOGS')
81    # Convert from list to colon-delimited string.
82    ffdc_function_list = ':'.join(ffdc_function_list)
83    print(ffdc_function_list)
84
85
86main()
87