update.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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) 2010/2019 | 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://code.03c8.net/epsylon/xsser"
  27. GIT_REPOSITORY2 = "https://github.com/epsylon/xsser"
  28. rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', ''))
  29. if not os.path.exists(os.path.join(rootDir, ".git")):
  30. print "[Error] Not any .git repository found!\n"
  31. print "="*30
  32. print "\nTo have working this feature, you should clone XSSer with:\n"
  33. print "$ git clone %s" % GIT_REPOSITORY
  34. print "\nAlso you can try this other mirror:\n"
  35. print "$ git clone %s" % GIT_REPOSITORY2 + "\n"
  36. else:
  37. checkout = execute("git checkout . && git pull", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
  38. print checkout
  39. if not "Already up-to-date" in checkout:
  40. print "Congratulations!! XSSer has been updated... ;-)\n"
  41. else:
  42. print "Your XSSer doesn't need to be updated... ;-)\n"