update.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', ''))
  21. if not os.path.exists(os.path.join(rootDir, ".git")):
  22. print("Not any .git repository found!\n")
  23. print("="*30)
  24. print("\nTo have working this feature, you should clone UFONet with:\n")
  25. print("$ git clone %s" % GIT_REPOSITORY)
  26. print("\nAlso you can try this other mirror:\n")
  27. print("$ git clone %s" % GIT_REPOSITORY2 + "\n")
  28. else:
  29. checkout = execute("git checkout . && git pull", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
  30. print(checkout)
  31. if not "Already up-to-date" in checkout:
  32. print("Congratulations!! UFONet has been updated... ;-)\n")
  33. else:
  34. print("Your UFONet doesn't need to be updated... ;-)\n")