blob: f8453e4b711f4db618d30239cd47eefd6e678450 [file] [log] [blame]
Alex Savatieievc9055712019-03-01 14:43:56 -06001import os
2
3from cfg_checker.common.exception import ConfigException
4
5
Alex41485522019-04-12 17:26:18 -05006def get_arg(args, str_arg):
7 _attr = getattr(args, str_arg)
8 if _attr:
9 return _attr
Alex Savatieievc9055712019-03-01 14:43:56 -060010 else:
Alex41485522019-04-12 17:26:18 -050011 _c = args.command if hasattr(args, 'command') else ''
12 _t = args.type if hasattr(args, 'type') else ''
13 raise ConfigException(
14 "Argument '{}' not found executing: mcp_check {} {}".format(
15 str_arg,
16 _c,
17 _t
18 )
19 )
Alex Savatieievc9055712019-03-01 14:43:56 -060020
21
22def get_path_arg(path):
23 if os.path.exists(path):
24 return path
25 else:
26 raise ConfigException("'{}' not exists".format(path))
Alex41485522019-04-12 17:26:18 -050027
28
29def get_report_type_and_filename(args):
30 if args.html or args.csv:
31 if args.html and args.csv:
32 raise ConfigException("Multuple report types not supported")
33 if args.html is not None:
34 return 'html', args.html
35 if args.csv is not None:
36 return 'csv', args.csv
37 else:
38 raise ConfigException("Report type and filename not set")