| George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 2 |  | 
| Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 3 | from gen_print import * | 
 | 4 | from gen_arg import * | 
 | 5 | from gen_valid import * | 
| Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 6 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 7 | parser = argparse.ArgumentParser( | 
 | 8 |     usage='%(prog)s [OPTIONS]', | 
 | 9 |     description="%(prog)s will...", | 
| Michael Walsh | d0741f8 | 2017-12-21 14:04:21 -0600 | [diff] [blame] | 10 |     formatter_class=argparse.ArgumentDefaultsHelpFormatter, | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 11 |     prefix_chars='-+') | 
 | 12 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 13 | parser.add_argument( | 
 | 14 |     '--whatever', | 
| Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 15 |     default='', | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 16 |     help='bla, bla.') | 
 | 17 |  | 
| Michael Walsh | 41dda1b | 2017-09-14 11:42:29 -0500 | [diff] [blame] | 18 | # Populate stock_list with options we want. | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 19 | stock_list = [("test_mode", 0), ("quiet", 0), ("debug", 0)] | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 20 |  | 
 | 21 |  | 
| Michael Walsh | ee24ff5 | 2019-12-13 14:42:59 -0600 | [diff] [blame] | 22 | def exit_function(): | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 23 |     r""" | 
| Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 24 |     Execute whenever the program ends normally or with the signals that we catch (i.e. TERM, INT).  This | 
 | 25 |     function will be called by gen_exit_function(). | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 26 |     """ | 
 | 27 |  | 
| Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 28 |     # If you have no cleanup to do, you can delete this function altogether. | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 29 |  | 
 | 30 |     # Your cleanup code here. | 
 | 31 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 32 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 33 | def validate_parms(): | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 34 |     r""" | 
| Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 35 |     Validate program parameters, etc.  This function will be called by gen_setup(). | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 36 |     """ | 
 | 37 |  | 
| Michael Walsh | 6db1b7d | 2020-02-18 11:51:23 -0600 | [diff] [blame] | 38 |     # If you have no validation to do, you can delete this function altogether. | 
| Michael Walsh | 6607a28 | 2019-09-13 14:21:01 -0500 | [diff] [blame] | 39 |  | 
| Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 40 |     # Your validation code here... | 
 | 41 |     # valid_value(whatever) | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 42 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 43 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 44 | def main(): | 
 | 45 |  | 
| Michael Walsh | 6607a28 | 2019-09-13 14:21:01 -0500 | [diff] [blame] | 46 |     gen_setup() | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 47 |  | 
 | 48 |     # Your code here. | 
 | 49 |  | 
| Michael Walsh | 4cae87d | 2017-01-12 14:46:05 -0600 | [diff] [blame] | 50 |  | 
| Michael Walsh | 2d8d7f3 | 2018-06-01 15:21:09 -0500 | [diff] [blame] | 51 | main() |