update.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-"
  3. # vim: set expandtab tabstop=4 shiftwidth=4:
  4. """
  5. This file is part of the xsser project, https://xsser.03c8.net
  6. Copyright (c) 2011/2016/2018 psy <epsylon@riseup.net>
  7. xsser is free software; you can redistribute it and/or modify it under
  8. the terms of the GNU General Public License as published by the Free
  9. Software Foundation version 3 of the License.
  10. xsser is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  13. details.
  14. You should have received a copy of the GNU General Public License along
  15. with xsser; if not, write to the Free Software Foundation, Inc., 51
  16. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. """
  18. import os
  19. from subprocess import PIPE
  20. from subprocess import Popen as execute
  21. class Updater(object):
  22. """
  23. Update XSSer automatically from a .git repository
  24. """
  25. def __init__(self):
  26. GIT_REPOSITORY = "https://github.com/epsylon/xsser"
  27. rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '../../', ''))
  28. if not os.path.exists(os.path.join(rootDir, ".git")):
  29. print "Not any .git repository found!\n"
  30. print "="*30
  31. print "\nTo have working this feature, you should clone XSSer with:\n"
  32. print "$ git clone %s" % GIT_REPOSITORY, "\n"
  33. else:
  34. checkout = execute("git checkout . && git pull", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
  35. print checkout
  36. if not "Already up-to-date" in checkout:
  37. print "Congratulations!! XSSer has been updated... ;-)"
  38. else:
  39. print "Your XSSer doesn't need to be updated... ;-)"