Skip to content

Commit 8543333

Browse files
committed
Add proper handle for unable for access error
1 parent 5240c4f commit 8543333

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

src/Utilities/git_utilities.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ def git_action(*args):
2323
if (pull_proc_out.decode('utf-8')).count("Already up-to-date.") == 1 or \
2424
(pull_proc_out.decode('utf-8')).count("Already up to date.") == 1:
2525
return True
26+
elif (pull_proc_out.decode('utf-8')).count("fatal: unable for access") != 0:
27+
sys_exit(1)
2628

2729
elif len(args) == 3 and args[0] == "clone":
2830
print("git clone {repo} {path}".format(repo=args[1], path=args[2]))
29-
_ = call(["git", "clone", args[1], args[2]])
31+
clone_proc_out = check_output(["git", "clone", args[1], args[2]])
32+
if (clone_proc_out.decode('utf-8')).count("fatal: unable for access") != 0:
33+
sys_exit(1)
3034

3135
else:
3236
print("Unexpected args error.")

updater.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from src.Utilities.installer import make_action
1616
from src.Utilities.installer import check_make_installation_status
1717

18-
UPDATER_VER = "1.1.4"
18+
UPDATER_VER = "1.2.0"
1919
GIT_DOWNLOAD_PAGE = "http://git-scm.com/"
2020
VIM_DOWNLOAD_PAGE = "https://www.vim.org/download.php#pc"
2121
VIM_REPO = "https://github.com/vim/vim.git"
@@ -29,8 +29,13 @@ def clean_install():
2929
Function to perform clean installation of vim: `git clone` and `make install`
3030
:return:
3131
"""
32-
print("Starting git clone, it may not be quite fast")
33-
git_action("clone", VIM_REPO, USER_FOLDER + UPDATER_DIR)
32+
print("Starting git clone, it may not be quite fast.")
33+
try:
34+
git_action("clone", VIM_REPO, USER_FOLDER + UPDATER_DIR)
35+
except Exception:
36+
print("Fatal error: unable for access.\nCheck internet connection.")
37+
sys_exit(1)
38+
3439
print("Current vim version in src:\n" + check_current_vim_version_in_src(USER_FOLDER + UPDATER_DIR))
3540
make_action("make", USER_FOLDER + UPDATER_DIR)
3641
make_action("install", USER_FOLDER + UPDATER_DIR)
@@ -104,27 +109,30 @@ def main():
104109
git_status=git_version_output))
105110

106111
if path.isdir(USER_FOLDER) and path.exists(USER_FOLDER + UPDATER_DIR):
107-
print("Work folder and updater dir here, check vim src folder")
112+
print("Work folder and updater dir here, checking vim src folder")
108113
if path.exists(USER_FOLDER + UPDATER_DIR):
109-
print("VIM folder here")
110114
if not path.exists(USER_FOLDER + UPDATER_DIR + "/.git"):
111-
print("Can't find .git folder")
112-
print("Removing work folder")
115+
print("Can't find .git folder.")
116+
print("Removing work folder")
113117
rmtree(USER_FOLDER + UPDATER_DIR)
114-
print("Work folder remover successfully, please run updater again")
118+
print("Work folder remover successfully, please run updater again.")
115119
sys_exit(0)
116120

117121
print("Pulling from github...")
118-
is_updated = git_action("pull", USER_FOLDER + UPDATER_DIR)
122+
try:
123+
is_updated = git_action("pull", USER_FOLDER + UPDATER_DIR)
124+
except Exception:
125+
print("Fatal error: unable for access.\nCheck internet connection.")
126+
sys_exit(1)
119127

120128
if is_updated:
121-
print("VIM already up to date\n")
129+
print("VIM already up to date.\n")
122130
print(check_current_vim_version_in_system())
123131
sys_exit(0)
124132
print(check_current_vim_version_in_src(USER_FOLDER + UPDATER_DIR))
125133
make_action("make", USER_FOLDER + UPDATER_DIR)
126134
make_action("install", USER_FOLDER + UPDATER_DIR)
127-
print("vim updated to {}".format(check_current_vim_version_in_system()))
135+
print("vim updated to {}.".format(check_current_vim_version_in_system()))
128136

129137
else:
130138
clean_install()
@@ -144,7 +152,7 @@ def main():
144152
clean_install()
145153

146154
else:
147-
print("Error with user folder: {user_folder}".format(user_folder=USER_FOLDER))
155+
print("Error with user folder: {user_folder}.".format(user_folder=USER_FOLDER))
148156
sys_exit(1)
149157

150158

0 commit comments

Comments
 (0)