def pacman_install(pkgs): text_helper.print_header('[PACMAN] Instalando: ' + " ".join(pkgs)) try: sh.contrib.sudo.pacman('-S', '--noconfirm', " ".join(pkgs)) except: text_helper.print_error('[PACMAN] Hubo un error en la instalacion') return False text_helper.new_line() return True
def pacman_upgrade(pkgs): text_helper.print_header('[PACMAN] Actualizando: ' + " ".join(pkgs)) try: sh.contrib.sudo.pacman('-U', '--noconfirm', " ".join(pkgs)) except: text_helper.print_error('[PACMAN] Hubo un error en la actualizacion') return False text_helper.new_line() return True
def yes_no_query(prompt): choice = input(prompt + ' [Yes/No] ').lower() if choice in yes: return True elif choice in no: return False else: text_helper.print_error('Responde con si o no...')
def yay_get_upgradable(): text_helper.print_header('[YAY] Obteniendo paquetes actualizables') try: pkg_list = sh.yay('-Qu') except sh.exit_code != 0: text_helper.print_error( '[YAY] Hubo un error al obtener la lista de paquetes actualizables') return False text_helper.new_line() return pkg_list
def yay_get_installed(): text_helper.print_header('[YAY] Obteniendo paquetes instalados') try: pkg_list = sh.yay('-Q') except sh.exit_code != 0: text_helper.print_error( '[YAY] Hubo un error al obtener la lista de paquetes instalados') return False text_helper.new_line() return pkg_list
def yay_upgrade(pkgs): text_helper.print_header('[YAY] Actualizando: ' + " ".join(pkgs)) try: sh.yay('-U', '--noconfirm', " ".join(pkgs)) except: text_helper.print_error('[YAY] Hubo un error en la actualizacion') return False text_helper.new_line() return True
def yay_install(pkgs): text_helper.print_header('[YAY] Instalando: ' + " ".join(pkgs)) try: sh.yay('-S', '--noconfirm', " ".join(pkgs)) except sh.exit_code != 0: text_helper.print_error( '[YAY] Hubo un error en la instalacion de los paquetes') return False text_helper.new_line() return True
def pacman_get_upgradable(): text_helper.print_header('[PACMAN] Obteniendo paquetes actualizables') try: pkg_list = sh.pacman('-Qu') except: text_helper.print_error( '[PACMAN] Hubo un error al obtener la lista de paquetes actualizables') return False text_helper.new_line() return pkg_list
def pacman_get_installed(): text_helper.print_header('[PACMAN] Obteniendo paquetes instalados') try: pkg_list = sh.pacman('-Q') except: text_helper.print_error( '[PACMAN] Hubo un error al obtener la lista de paquetes instalados') return False text_helper.new_line() return pkg_list
def git_set_email_and_name(email, name): text_helper.print_info('[GIT] Seteando email y usuario') try: git('config', '--global', 'user.email', email) git('config', '--global', 'user.name', name) except: text_helper.print_error( '[GIT] Hubo un error seteando el mail y usuario') return False text_helper.print_success( '[GIT] Mail y usario seteados satisfactoriamente')
def git_set_credentials(password, username): text_helper.print_info('[GIT] Seteando credenciales') try: git('config', '--global', 'credential.https://github.com.username', username) git('config', '--global', 'credential.https://github.com.password', password) except: text_helper.print_error( '[GIT] Hubo un error seteando las credenciales') return False text_helper.print_success('[GIT] Credenciales seteadas satisfactoriamente')
def git_clone(repo): text_helper.print_info('[GIT] Clonando: ' + utils.take_repo_name(repo)) try: git('clone', repo, './Workspace/' + utils.take_repo_name(repo), _cwd=pathlib.Path.home()) except: text_helper.print_error( '[GIT] Hubo un error al intentar clonar el repositorio') return False text_helper.print_success('[GIT] Se clono satisfactoriamente: ' + utils.take_repo_name(repo))
def build_config(): text_helper.print_info('Cargando configuraciones') text_helper.new_line() config_dict = dict() for index, filename in enumerate(os.listdir(CONFIG_PATH), start=1): print('Cargando ' + filename + '...') text_helper.separator() file = open(CONFIG_PATH + filename) data = json.load(file) if 'name' not in data: text_helper.print_error( 'El archivo ' + filename + ' no tiene una key "name", no fue agregado como opcion') continue if 'apps' not in data and 'commands' not in data: text_helper.print_error( 'El archivo ' + filename + ' no tiene apps, no fue agregado como opcion') continue config_dict[index] = {} config_dict[index]['name'] = data['name'] if 'apps' in data: config_dict[index]['apps'] = data['apps'] else: text_helper.print_warning( 'El archivo ' + filename + ' no tiene ninguna app') if 'clone' in data: config_dict[index]['clone'] = data['clone'] else: text_helper.print_warning( 'El archivo ' + filename + ' no tiene ningun repositorio a clonar') if 'zsh' in data: config_dict[index]['zsh'] = data['zsh'] text_helper.print_info('Se configurarab Zsh y Oh-my-Zsh') else: text_helper.print_info('Zsh y Oh-my-Zsh no se configuraran') text_helper.print_success( 'Archivo ' + filename + ' cargado satisfactoriamente') text_helper.new_line() return config_dict
def print_desc(name): if name in api_names: return text_helper.print_error( 'CUIDADO, ESTAS A PUNTO DE ENTRAR EN LA DICTADURA DE IGNACIO CAPUCCIO' ) if name in web_names: return text_helper.print_success( 'Buena capo, entraste al mejor team de Widergy!') if name in mobile_names: return text_helper.print_warning('SORRY, APP CRASHED, TRY AGAIN LATER')
def execute_config(config): if (utils.yes_no_query('Configuramos git?')): if _git_config(): text_helper.print_success('Listo! Git configurado') else: text_helper.print_error('Hubo un error al configurar git') if not utils.yes_no_query('Seguimos?'): exit() if not pkg_manager_helper.pacman_install(['yay']): text_helper.print_error( 'Yay no pudo ser instalado... Saliendo del configurador...') exit() text_helper.print_header('Chequeando paquetes...') filtered_packages = utils.filter_packages(config['apps']) if filtered_packages['upgradable']: text_helper.print_header('Paquetes actualizables: ' + " ".join(filtered_packages['upgradable'])) if utils.yes_no_query('Actualizar paquetes?'): pkg_manager_helper.yay_upgrade(filtered_packages['upgradable']) else: text_helper.print_info( 'No hay paquetes con actualizaciones disponibles') if filtered_packages['installed']: text_helper.print_info( 'Los siguientes paquetes estan instalados y actualizados, se omitiran: ' + " ".join(filtered_packages['installed'])) if filtered_packages['to_install']: if not pkg_manager_helper.yay_install(filtered_packages['to_install']): exit() else: text_helper.print_info('No hay paquetes para instalar')