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