update.py 1.8 KB

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