added timeouts and devnulls + confirmation for user
This commit is contained in:
@@ -14,6 +14,9 @@ import gdown
|
|||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.theme import Theme
|
from rich.theme import Theme
|
||||||
|
|
||||||
|
# pylint: disable=subprocess-run-check
|
||||||
|
# pylint: disable=broad-exception-caught
|
||||||
|
# pylint: disable=logging-fstring-interpolation
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s | %(levelno)s | %(funcName)s| %(message)s ",
|
format="%(asctime)s | %(levelno)s | %(funcName)s| %(message)s ",
|
||||||
@@ -29,8 +32,19 @@ home = os.path.join('/home',user)
|
|||||||
def main():
|
def main():
|
||||||
|
|
||||||
setup = ''
|
setup = ''
|
||||||
|
confirm_user =''
|
||||||
|
|
||||||
sudo_check()
|
sudo_check()
|
||||||
|
|
||||||
|
console.print(f"Setting up for user {user} ", style='promp')
|
||||||
|
while(True):
|
||||||
|
confirm_user = input(" y/n ")
|
||||||
|
if (confirm_user.lower() == 'n'):
|
||||||
|
exit()
|
||||||
|
elif (confirm_user.lower() == 'y'):
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
#set temporary resolution for sesion
|
#set temporary resolution for sesion
|
||||||
user_answer = input("Set resolution 1920x1080? y/n: ").lower()
|
user_answer = input("Set resolution 1920x1080? y/n: ").lower()
|
||||||
console.print("Run aranddr to proper set up", style='ok')
|
console.print("Run aranddr to proper set up", style='ok')
|
||||||
@@ -60,6 +74,9 @@ def main():
|
|||||||
executable_scripts()
|
executable_scripts()
|
||||||
msic_configs()
|
msic_configs()
|
||||||
|
|
||||||
|
#correcting ownership
|
||||||
|
subprocess.run(f"chown -R {user}:{user} {home}",shell=True ,stdout=subprocess.DEVNULL)
|
||||||
|
|
||||||
################
|
################
|
||||||
# END OF MAIN #
|
# END OF MAIN #
|
||||||
################
|
################
|
||||||
@@ -126,8 +143,8 @@ def pip_modules(modules):
|
|||||||
|
|
||||||
## checks for sudo
|
## checks for sudo
|
||||||
def sudo_check():
|
def sudo_check():
|
||||||
user = os.getenv("SUDO_USER")
|
sudo_user = os.getenv("SUDO_USER")
|
||||||
if user is None:
|
if sudo_user is None:
|
||||||
console.print("This program must run as sudo -HE ./script ", style='error')
|
console.print("This program must run as sudo -HE ./script ", style='error')
|
||||||
exit()
|
exit()
|
||||||
else:
|
else:
|
||||||
@@ -142,7 +159,7 @@ def zsh_fonts():
|
|||||||
|
|
||||||
#installs oh my zsh
|
#installs oh my zsh
|
||||||
ohmy_url = "https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh"
|
ohmy_url = "https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh"
|
||||||
zsh_installer = requests.get(ohmy_url)
|
zsh_installer = requests.get(ohmy_url, timeout=10)
|
||||||
open('install.sh', 'wb').write(zsh_installer.content)
|
open('install.sh', 'wb').write(zsh_installer.content)
|
||||||
subprocess.run('chmod +x install.sh ', stdout=subprocess.DEVNULL, shell=True, check=True)
|
subprocess.run('chmod +x install.sh ', stdout=subprocess.DEVNULL, shell=True, check=True)
|
||||||
subprocess.run(f'sudo -u {user} ./install.sh', shell=True, check=True)
|
subprocess.run(f'sudo -u {user} ./install.sh', shell=True, check=True)
|
||||||
@@ -240,7 +257,7 @@ def msic_configs():
|
|||||||
|
|
||||||
#### i3 autotiling
|
#### i3 autotiling
|
||||||
autotiling_url = 'https://raw.githubusercontent.com/nwg-piotr/autotiling/master/autotiling/main.py'
|
autotiling_url = 'https://raw.githubusercontent.com/nwg-piotr/autotiling/master/autotiling/main.py'
|
||||||
tiler = requests.get(autotiling_url, allow_redirects=True)
|
tiler = requests.get(autotiling_url, allow_redirects=True, timeout=10)
|
||||||
open('autotiling', 'wb').write(tiler.content)
|
open('autotiling', 'wb').write(tiler.content)
|
||||||
subprocess.run('chmod +x autotiling', shell=True, stdout=subprocess.DEVNULL)
|
subprocess.run('chmod +x autotiling', shell=True, stdout=subprocess.DEVNULL)
|
||||||
subprocess.run('cp autotiling /bin', shell=True, stdout=subprocess.DEVNULL)
|
subprocess.run('cp autotiling /bin', shell=True, stdout=subprocess.DEVNULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user