Merge branch 'master' into decorate
This commit is contained in:
commit
a7c956fbab
2 changed files with 36 additions and 35 deletions
|
@ -326,7 +326,7 @@
|
|||
|
||||
#####################################[ vcs: git status ]######################################
|
||||
# Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
|
||||
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON=
|
||||
typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 '
|
||||
|
||||
# Untracked files icon. It's really a question mark, your font isn't broken.
|
||||
# Change the value of this parameter to show a different icon.
|
||||
|
|
69
install.py
69
install.py
|
@ -42,43 +42,48 @@ class Installer:
|
|||
def define_os(self) -> str:
|
||||
"""Define what OS we are using."""
|
||||
|
||||
os_release = Path("/etc/os-release")
|
||||
|
||||
oses = ("arch", "debian", "manjaro", "ubuntu")
|
||||
os_release = Path("/etc/os-release")
|
||||
operating_system = None
|
||||
for operating_system in oses:
|
||||
if operating_system in os_release.read_text().lower():
|
||||
ui.info_3("Found", operating_system, "based distribution")
|
||||
break
|
||||
|
||||
if operating_system is None:
|
||||
ui.warning("Operating system wasn't found")
|
||||
operating_system = input("What is it ? ")
|
||||
|
||||
if operating_system in ("arch", "debian"):
|
||||
self._update_system(operating_system)
|
||||
return operating_system
|
||||
|
||||
ui.fatal("I only support Arch and Debian based distros.")
|
||||
return "Unsupported OS"
|
||||
|
||||
def _update_system(self, operating_system: str) -> None:
|
||||
# defaults for subprocess.run()
|
||||
this_stdout: Optional[int] = subprocess.DEVNULL if self.hide_commands else None
|
||||
this_stderr: Optional[int] = subprocess.DEVNULL if self.hide_commands else None
|
||||
|
||||
for operating_system in oses:
|
||||
if operating_system in os_release.read_text().lower():
|
||||
ui.info_3("Found", operating_system, "based distribution")
|
||||
if operating_system in ("arch", "manjaro"):
|
||||
command = "sudo pacman -Syu"
|
||||
operating_system = "arch"
|
||||
|
||||
if operating_system in ("arch", "manjaro"):
|
||||
command = "sudo pacman -Syu"
|
||||
operating_system = "arch"
|
||||
elif operating_system in ("debian", "ubuntu"):
|
||||
command = "sudo apt update"
|
||||
operating_system = "debian"
|
||||
|
||||
if operating_system in ("debian", "ubuntu"):
|
||||
command = "sudo apt update"
|
||||
operating_system = "debian"
|
||||
else:
|
||||
raise AssertionError("The operating system should have been defined")
|
||||
|
||||
subprocess.run(
|
||||
command,
|
||||
check=True,
|
||||
shell=True,
|
||||
stdout=this_stdout,
|
||||
stderr=this_stderr,
|
||||
)
|
||||
return operating_system
|
||||
|
||||
ui.warning("Operating system wasn't found")
|
||||
operating_system = input("What is it ? ")
|
||||
if operating_system in ("arch", "debian"):
|
||||
return operating_system
|
||||
|
||||
ui.fatal("I only support Arch and Debian based distros.")
|
||||
|
||||
return "Unsupported OS"
|
||||
subprocess.run(
|
||||
command,
|
||||
check=True,
|
||||
shell=True,
|
||||
stdout=this_stdout,
|
||||
stderr=this_stderr,
|
||||
)
|
||||
|
||||
def evaluate_condition(self, condition: str) -> bool:
|
||||
"""Run a bash command. On success return True, else return False."""
|
||||
|
@ -214,6 +219,7 @@ class Installer:
|
|||
command = "sudo apt install -y {}".format(package)
|
||||
|
||||
ui.info_count(i, len(packages), package, end="... ")
|
||||
|
||||
install = subprocess.run(
|
||||
command,
|
||||
check=False,
|
||||
|
@ -234,12 +240,7 @@ class Installer:
|
|||
for failed in failed_installs:
|
||||
ui.info(" ", failed)
|
||||
|
||||
ui.info(
|
||||
ui.yellow,
|
||||
"Are the packages really meant for {} systems?".format(
|
||||
self.operating_system
|
||||
),
|
||||
)
|
||||
ui.warning(f"Are the packages really meant for {self.operating_system} systems?")
|
||||
|
||||
def do_run(self, command: str, condition: str = "true") -> None:
|
||||
"""Run a command."""
|
||||
|
|
Loading…
Add table
Reference in a new issue