convertdb.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. #============================================================================
  17. # Copyright (C) 2013 Oz Nahum <nahumoz@gmail.com>
  18. #============================================================================
  19. import os
  20. import shutil
  21. import os.path
  22. import time
  23. class PwmanConvertDB(object):
  24. """
  25. Class to migrate from DB in version 0.3 to
  26. DB used in later versions.
  27. """
  28. def __init__(self, args, config):
  29. db = config.get_value('Database', 'filename')
  30. print "Will convert the following Database: %s " % db
  31. backup = '.backup-%s'.join(os.path.splitext(db)) % \
  32. time.strftime(
  33. '%Y-%m-%d-%H:%m')
  34. shutil.copy(db, backup)
  35. print "backup created in ", backup
  36. def run(self):
  37. pass