update.py 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-"
  3. """
  4. PyDog4Apache - 2016/2022 - by psy (epsylon@riseup.net)
  5. You should have received a copy of the GNU General Public License along
  6. with PyDog4Apache; if not, write to the Free Software Foundation, Inc., 51
  7. Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  8. """
  9. import os
  10. from subprocess import PIPE
  11. from subprocess import Popen as execute
  12. class Updater(object):
  13. def __init__(self):
  14. GIT_REPOSITORY = "https://code.03c8.net/epsylon/pydog4apache"
  15. GIT_REPOSITORY2 = "https://github.com/epsylon/pydog4apache"
  16. rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', ''))
  17. if not os.path.exists(os.path.join(rootDir, ".git")):
  18. print("-"*22)
  19. print("\n[Info] Not any .git repository found!")
  20. print("\nTo have working this feature, you should clone pydgo4apache with:\n")
  21. print("$ git clone %s" % GIT_REPOSITORY)
  22. print("\nAlso you can try this other mirror:\n")
  23. print("$ git clone %s" % GIT_REPOSITORY2 + "\n")
  24. else:
  25. checkout = execute("git checkout . && git pull", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
  26. print(checkout)
  27. if not "Already up-to-date" in checkout:
  28. print("Congratulations!! pydog4apache has been updated... ;-)\n")
  29. else:
  30. print("Your pydog4apache doesn't need to be updated... ;-)\n")