Reformat
This commit is contained in:
parent
e5ea9e8356
commit
c4da2e78ee
|
@ -335,6 +335,7 @@ WEB_INSTALLS = [
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def extra_installs():
|
def extra_installs():
|
||||||
rustup_cmd = [
|
rustup_cmd = [
|
||||||
"bash",
|
"bash",
|
||||||
|
@ -359,9 +360,7 @@ def extra_installs():
|
||||||
if not shutil.which("rustc") and prompt_user("rustup"):
|
if not shutil.which("rustc") and prompt_user("rustup"):
|
||||||
subprocess.call(rustup_cmd)
|
subprocess.call(rustup_cmd)
|
||||||
|
|
||||||
has_tmp = os.path.exists(
|
has_tmp = os.path.exists(f"{os.environ['HOME']}/.config/tmux/plugins/tpm/tpm")
|
||||||
f"{os.environ['HOME']}/.config/tmux/plugins/tpm/tpm"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not has_tmp and prompt_user("tmp, tmux's package manager"):
|
if not has_tmp and prompt_user("tmp, tmux's package manager"):
|
||||||
success = subprocess.call(tmp_cmds[0]) == 0
|
success = subprocess.call(tmp_cmds[0]) == 0
|
||||||
|
@ -386,14 +385,15 @@ def find_package_manager():
|
||||||
else:
|
else:
|
||||||
raise Exception("Supported package manager not found")
|
raise Exception("Supported package manager not found")
|
||||||
|
|
||||||
|
|
||||||
def check_installed(pkg, apt):
|
def check_installed(pkg, apt):
|
||||||
if pkg.get("executable_name") and shutil.which(pkg['executable_name']):
|
if pkg.get("executable_name") and shutil.which(pkg["executable_name"]):
|
||||||
return "true"
|
return "true"
|
||||||
elif not pkg.get(apt['name']):
|
elif not pkg.get(apt["name"]):
|
||||||
return "unavailable"
|
return "unavailable"
|
||||||
|
|
||||||
check_cmd = list(apt["check_installed"])
|
check_cmd = list(apt["check_installed"])
|
||||||
check_cmd.append(pkg[apt['name']])
|
check_cmd.append(pkg[apt["name"]])
|
||||||
|
|
||||||
check = subprocess.Popen(
|
check = subprocess.Popen(
|
||||||
check_cmd,
|
check_cmd,
|
||||||
|
@ -408,18 +408,20 @@ def check_installed(pkg, apt):
|
||||||
else:
|
else:
|
||||||
return "false"
|
return "false"
|
||||||
|
|
||||||
|
|
||||||
def prompt_user(pkg_name):
|
def prompt_user(pkg_name):
|
||||||
while True:
|
while True:
|
||||||
user_in = input(f"Install {pkg_name}? (Y/n) ")
|
user_in = input(f"Install {pkg_name}? (Y/n) ")
|
||||||
|
|
||||||
if user_in == "" or user_in[0].lower() == 'y':
|
if user_in == "" or user_in[0].lower() == "y":
|
||||||
return True
|
return True
|
||||||
elif user_in[0].lower() == 'n':
|
elif user_in[0].lower() == "n":
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def install_package(apt, package):
|
def install_package(apt, package):
|
||||||
install_cmd = list(apt['install_cmd'])
|
install_cmd = list(apt["install_cmd"])
|
||||||
install_cmd.append(package[apt['name']])
|
install_cmd.append(package[apt["name"]])
|
||||||
|
|
||||||
install = subprocess.call(install_cmd)
|
install = subprocess.call(install_cmd)
|
||||||
|
|
||||||
|
@ -430,7 +432,7 @@ def install_packages(apt):
|
||||||
global PACKAGES
|
global PACKAGES
|
||||||
|
|
||||||
for package in PACKAGES:
|
for package in PACKAGES:
|
||||||
pkg_name = package['global_name']
|
pkg_name = package["global_name"]
|
||||||
installed = check_installed(package, apt)
|
installed = check_installed(package, apt)
|
||||||
|
|
||||||
if installed == "unavailable":
|
if installed == "unavailable":
|
||||||
|
@ -445,20 +447,21 @@ def install_packages(apt):
|
||||||
else:
|
else:
|
||||||
print(f"φ Not installing {pkg_name}")
|
print(f"φ Not installing {pkg_name}")
|
||||||
|
|
||||||
|
|
||||||
def web_installs():
|
def web_installs():
|
||||||
global WEB_INSTALLS
|
global WEB_INSTALLS
|
||||||
|
|
||||||
for package in WEB_INSTALLS:
|
for package in WEB_INSTALLS:
|
||||||
if not os.path.exists(package['dest']) and prompt_user(package['name']):
|
if not os.path.exists(package["dest"]) and prompt_user(package["name"]):
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
"curl",
|
"curl",
|
||||||
"--output",
|
"--output",
|
||||||
package['dest'],
|
package["dest"],
|
||||||
package['url'],
|
package["url"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
apt = find_package_manager()
|
apt = find_package_manager()
|
||||||
print(f"Identified `{apt['name']}` as system package manager")
|
print(f"Identified `{apt['name']}` as system package manager")
|
||||||
|
|
Loading…
Reference in a new issue