collect.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #
  2. # Metrix++, Copyright 2009-2013, Metrix++ Project
  3. # Link: http://metrixplusplus.sourceforge.net
  4. #
  5. # This file is a part of Metrix++ Tool.
  6. #
  7. # Metrix++ is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, version 3 of the License.
  10. #
  11. # Metrix++ is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with Metrix++. If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. import logging
  20. import os.path
  21. import time
  22. import core.loader
  23. import core.log
  24. import core.cmdparser
  25. def main():
  26. loader = core.loader.Loader()
  27. parser =core.cmdparser.MultiOptionParser(usage="Usage: %prog [options] -- [path 1] ... [path N]")
  28. args = loader.load(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'ext'), parser)
  29. logging.debug("Registered plugins:")
  30. logging.debug(loader)
  31. exit_code = loader.run(args)
  32. loader.unload()
  33. return exit_code
  34. if __name__ == '__main__':
  35. ts = time.time()
  36. core.log.set_default_format()
  37. exit_code = main()
  38. logging.warning("Exit code: " + str(exit_code) + ". Time spent: " + str(round((time.time() - ts), 2)) + " seconds. Done")
  39. exit(exit_code) # number of reported messages, errors are reported as non-handled exceptions