update.py 1.5 KB

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