-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup_tools.py
65 lines (55 loc) · 2.04 KB
/
setup_tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
""" Installation for necessary tools. """
from halo import Halo
import sh
import logging
from cli import user_input
BREW_GITHUB = (
"https://raw.githubusercontent.com/Homebrew/install/master/install"
)
def install_homebrew():
""" Installs or upgrades homebrew on mac.
If homebrew is not installed, this command will install it, otherwise
it will update homebrew to the latest version. Additionally, it will
offer to upgrade all homebrew packages. Upgrading all packages can take
a long time, so the user is given the choice to skip the upgrade.
"""
print("Checking homebrew install")
if sh.which("brew"):
spinner = Halo(
text="Updating homebrew", spinner="dots", placement="right"
)
spinner.start()
sh.brew("update")
spinner.succeed()
print(
"Before using homebrew to install packages, we can upgrade "
"any outdated packages."
)
response = user_input("Run brew upgrade? [y|N] ")
if response[0].lower() == "y":
spinner = Halo(
text="Upgrade brew packages", spinner="dots", placement="right"
)
spinner.start()
sh.brew("upgrade")
spinner.succeed()
else:
print("Skipped brew package upgrades")
else:
# TODO (phillip): Currently, this homebrew installation does not work on a fresh
# computer. It works from the command line, but not when run from the script. I
# need to figure out what is going on. It could be because user input is needed.
spinner = Halo(
text="Installing homebrew", spinner="dots", placement="right"
)
spinner.start()
try:
script = sh.curl("-fsSL", BREW_GITHUB).stdout
sh.ruby("-e", script)
spinner.succeed()
except sh.ErrorReturnCode:
logging.error("Unable to install homebrew. Aborting...")
spinner.fail()
exit(1)
if __name__ == "__main__":
install_homebrew()