metrixpp.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #
  2. # Metrix++, Copyright 2009-2019, Metrix++ Project
  3. # Link: https://github.com/metrixplusplus/metrixplusplus
  4. #
  5. # This file is a part of Metrix++ Tool.
  6. #
  7. import time
  8. import sys
  9. import logging
  10. import os
  11. import itertools
  12. from .mpp import log
  13. from .mpp.internal import loader as plugin_loader
  14. def main():
  15. os.environ['METRIXPLUSPLUS_INSTALL_DIR'] = os.path.dirname(os.path.abspath(__file__))
  16. command = ""
  17. if len(sys.argv) > 1:
  18. command = sys.argv[1]
  19. loader = plugin_loader.Loader()
  20. mpp_paths = []
  21. if 'METRIXPLUSPLUS_PATH' in list(os.environ.keys()):
  22. mpp_paths = os.environ['METRIXPLUSPLUS_PATH'].split(os.pathsep)
  23. args = loader.load(command, mpp_paths, sys.argv[2:])
  24. exit_code = loader.run(args)
  25. loader.unload()
  26. return exit_code
  27. def start():
  28. ts = time.time()
  29. log.set_default_format()
  30. exit_code = main()
  31. time_spent = round((time.time() - ts), 2)
  32. if 'METRIXPLUSPLUS_TEST_GENERATE_GOLDS' in list(os.environ.keys()) and \
  33. os.environ['METRIXPLUSPLUS_TEST_GENERATE_GOLDS'] == "True":
  34. time_spent = 1 # Constant value if under tests
  35. logging.warning("Done (" + str(time_spent) +" seconds). Exit code: " + str(exit_code))
  36. exit(exit_code)
  37. if __name__ == '__main__':
  38. start()