diff options
author | Adrian Lane <adrian.lane@canonical.com> | 2020-04-05 21:31:01 -0700 |
---|---|---|
committer | Adrian Lane <adrian.lane@canonical.com> | 2020-04-05 21:31:01 -0700 |
commit | cd4a6e846cff5cad9502d63858eea4c73cc38be2 (patch) | |
tree | b7d6eaedd4a1f44e42ebbe9ef1a38579b622f947 | |
parent | 5367f311aae3060baa060f87ac4ee59eb027517f (diff) |
minor refactoring, syntax changes
-rwxr-xr-x | bin/ipmi_test.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/bin/ipmi_test.py b/bin/ipmi_test.py index 8d8af20..d8d02e8 100755 --- a/bin/ipmi_test.py +++ b/bin/ipmi_test.py @@ -64,7 +64,7 @@ class IpmiTest(object): try: path_full = shutil.which(sbin) return path_full - except self.subproc_excs[2:3]: + except (self.subproc_excs[2:3]): logging.info('Unable to stat path via shutil lib!') logging.info('Using relative paths...') path_full = sbin @@ -240,7 +240,7 @@ class IpmiTest(object): version = output[(res_index + 24):(res_index + 27)] logging.info(f'IPMI Version: {version}\n') # protect conditional - if float(version) < float(self.ipmi_ver): + if (float(version) < float(self.ipmi_ver)): logging.info(f'IPMI Version below {self.ipmi_ver}!\n') return 1 else: @@ -270,33 +270,14 @@ class IpmiTest(object): def main(): - # instantiate argparse as parser - parser = argparse.ArgumentParser() - parser.add_argument('-d', '--debug', action='store_true', - help='Debug/verbose output (stdout/stderr)') - parser.add_argument('-q', '--quiet', action='store_true', - help='Suppress output.') - args = parser.parse_args() - - # logging subsystem - if not args.quiet or args.debug: - logger = logging.getLogger() - logger.setLevel(logging.DEBUG) - - if not args.quiet: - console_handler = logging.StreamHandler() - console_handler.setLevel(logging.INFO) - logger.addHandler(console_handler) - - if args.debug: - console_handler.setLevel(logging.DEBUG) - + # init logging subsystem + init_logging() # instantiate IpmiTest as ipmi_test # pass to [results] for post-processing ipmi_test = IpmiTest() results = ipmi_test.run_test() # tally results - if sum(results) > 0: + if (sum(results) > 0): print ('-----------------------') print ('## IPMI tests failed! ##') print ( @@ -310,6 +291,25 @@ def main(): return 0 +def init_logging(): + # instantiate argparse as parser + parser = argparse.ArgumentParser() + parser.add_argument('-d', '--debug', action='store_true', + help='Debug/verbose output (stdout/stderr)') + parser.add_argument('-q', '--quiet', action='store_true', + help='Suppress output.') + args = parser.parse_args() + if (not args.quiet or args.debug): + logger = logging.getLogger() + logger.setLevel(logging.DEBUG) + if (not args.quiet): + console_handler = logging.StreamHandler() + console_handler.setLevel(logging.INFO) + logger.addHandler(console_handler) + if args.debug: + console_handler.setLevel(logging.DEBUG) + + # call main() if __name__ == '__main__': sys.exit(main()) |