info.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 time
  21. import core.db.loader
  22. import core.db.post
  23. import core.log
  24. import core.cmdparser
  25. def main():
  26. exit_code = 0
  27. log_plugin = core.log.Plugin()
  28. db_plugin = core.db.post.Plugin()
  29. parser = core.cmdparser.MultiOptionParser(usage="Usage: %prog [options]")
  30. log_plugin.declare_configuration(parser)
  31. db_plugin.declare_configuration(parser)
  32. (options, args) = parser.parse_args()
  33. log_plugin.configure(options)
  34. db_plugin.configure(options)
  35. args = args # used
  36. loader = core.db.loader.Loader()
  37. loader.open_database(db_plugin.dbfile)
  38. loader_prev = None
  39. if db_plugin.dbfile_prev != None:
  40. loader_prev = core.db.loader.Loader()
  41. loader_prev.open_database(db_plugin.dbfile_prev)
  42. print "Info data:"
  43. for each in loader.iterate_properties():
  44. prev_value_str = ""
  45. if loader_prev != None:
  46. prev = loader_prev.get_property(each.name)
  47. if prev != each.value:
  48. prev_value_str = " [previous value: " + loader_prev.get_property(each.name) + "]"
  49. print "(!)",
  50. print "\t" + each.name + "\t=>\t" + each.value + prev_value_str
  51. return exit_code
  52. if __name__ == '__main__':
  53. ts = time.time()
  54. core.log.set_default_format()
  55. exit_code = main()
  56. logging.warning("Exit code: " + str(exit_code) + ". Time spent: " + str(round((time.time() - ts), 2)) + " seconds. Done")
  57. exit(exit_code) # number of reported messages, errors are reported as non-handled exceptions