update.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-"
  3. """
  4. This file is part of the orb project, http://orb.03c8.net
  5. Orb - 2016/2017/2018 - by psy (epsylon@riseup.net)
  6. You should have received a copy of the GNU General Public License along
  7. with RedSquat; 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 Orb automatically from a .git repository
  16. """
  17. def __init__(self):
  18. GIT_REPOSITORY = "https://github.com/epsylon/orb"
  19. rootDir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', ''))
  20. if not os.path.exists(os.path.join(rootDir, ".git")):
  21. print "Not any .git repository found!\n"
  22. print "="*30
  23. print "\nTo have working this feature, you should clone Orb with:\n"
  24. print "$ git clone %s" % GIT_REPOSITORY
  25. else:
  26. checkout = execute("git checkout . && git pull", shell=True, stdout=PIPE, stderr=PIPE).communicate()[0]
  27. print checkout
  28. if not "Already up-to-date" in checkout:
  29. print "Congratulations!! Orb has been updated... ;-)\n"
  30. else:
  31. print "Your Orb doesn't need to be updated... ;-)\n"