def log_callback(record): _msg = record['msg'] _c = colors.red if record.get("levelname") == "ERROR" else colors.blue if isinstance(_msg, dict): __name = "wacai.log.error" if record.get( "levelname") == "ERROR" else "wacai.log.info" _r = Application.current().redis _c = _r.conn() if not _c: log.error("redis连接失败") log.error(_r.error_msg) _r.dis_conn() sys.stdout.write( colors.yellow( "[{name}] [{asctime} {host_ip}] {filename}[{module}.{funcName}][{lineno}]\n" .format(**record))) sys.stdout.write(_c("{levelname}: {msg}\n".format(**record))) else: _c.rpush(__name, json.dumps(record)) else: sys.stdout.write( colors.yellow( "[{name}] [{asctime} {host_ip}] {filename}[{module}.{funcName}][{lineno}]\n" .format(**record))) sys.stdout.write(_c("{levelname}: {msg}\n".format(**record)))
def main(connection, config, options): """This method takes the branch specified by --build and --search and tries to identify it on bamboo as specified in the .ini file. If there is a match the app performs the actions --download --extract --launch as specified on that build on all of the specified platforms in the required platform argument. """ loglevel = logging.DEBUG if options.verbose else logging.INFO logging.basicConfig(format='%(levelname)s: %(message)s', level=loglevel) try: logging.info( 'Checking Bamboo for plan %s, for build' ' %s, and for searchterm: %s', green(config['server']['bambookey']), yellow('#' + str(options.build)), green(options.search), ) build = BambooBuild( connection, searchterm=options.search, key=config['server']['bambookey'], buildnumber=options.build, ) except Exception as error: logging.error('No build found, reason: {0}'.format(red(str(error)))) return logging.info(' '.join([ 'Build found:', green(build.name), yellow('#' + str(build.buildnumber)) ])) try: bamboomanager = BambooManager(connection, config, build=build, platforms=options.platform) except Exception as error: logging.error( red('Building project failed, reason: {0}'.format(str(error)))) return logging.info('Artifacts found: {0}'.format( red(' '.join(bamboomanager.platforms)))) if options.download: bamboomanager.download() if options.extract: bamboomanager.extract() if options.launch: bamboomanager.launch()
def suggest_partitioning(): print("\nPlease, set your partitions now, format and mount them on " + yellow("/mnt") + ".") print("If all you want to do is to wipe all partitions and install " + cyan("Arch Linux") + ", you can run " + green("tali/quick_partitioning.py") + ".") print("Otherwise, you can format your partitions yourself with " + green("parted") + " or a similar tool.") print("\nWhen you're done, run " + green("tali/install.py") + ".\n")
def __init__(self, platform, bamboo, config): self.credentials = bamboo.connection.credentials self.os = platform self.branch = bamboo.build.name self.buildnumber = '#' + str(bamboo.build.buildnumber) self.path = bamboo.path + self.os + '/' self.app = self.path + config['appname'] self.url = BambooWrapper.artifactUrl(bamboo.connection, bamboo.build.masterkey, bamboo.build.buildnumber, config['filepath'], config['filename'], ) self.artifactfile = self.path + config['filename'] self.displayname = ' '.join([green(self.branch), yellow(self.buildnumber), red(self.os), ])
def __callback(self, record): if not self.callback: sys.stdout.write( colors.yellow( "[{name}] [{asctime} {host_ip}] {filename}[{module}.{funcName}][{lineno}]\n" .format(**record))) levelname = record.get("levelname") _c = colors.red if levelname == "ERROR" else colors.blue _msg = record['msg'] if isinstance(_msg, dict): sys.stdout.write(_c("{levelname}:\n".format(**record))) for k, v in _msg.items(): sys.stdout.write(_c(" {0}:{1}\n".format(k, v))) else: sys.stdout.write(_c("{levelname}: {msg}\n".format(**record))) else: self.callback(record)
from utils.colors import cyan, green, yellow from utils.select_kernel import select_kernel from utils.yes_no_dialog import yes_no_dialog good_to_go = yes_no_dialog("Did you set your partitions, format them and mount them on " + yellow("/mnt") + "?") if good_to_go: import os print() kernel_packages = select_kernel() os.system(f"pacstrap /mnt base base-devel {kernel_packages} linux-firmware net-tools xdg-user-dirs") os.system("pacstrap /mnt python wget") os.system("genfstab -U /mnt >> /mnt/etc/fstab") os.system("cp -r /root/tali /mnt/tali") os.system("cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist") os.system("arch-chroot /mnt python tali/install.py --step 3") else: # TODO: Make this a function, since this dialog is also used in step 1. print("\nPlease, set your partitions now, format and mount them on " + yellow("/mnt") + ".") print("If all you want to do is to wipe all partitions and install " + cyan("Arch Linux") + ", you can run " + green("tali/quick_partitioning.py") + ".") print("Otherwise, you can format your partitions yourself with " + green("parted") + " or a similar tool.") print("\nWhen you're done, run " + green("tali/install.py") + " again.\n")
os.system(f"echo root:{password1} | chpasswd") os.system(f"echo {username}:{password1} | chpasswd") os.system("cat /etc/sudoers | sed 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/g' > /etc/sudoers_new") enable_pwfeedback = yes_no_dialog("Would you like to enable password feedback?") if enable_pwfeedback: os.system("echo '\nDefaults pwfeedback' | tee -a /etc/sudoers_new") os.system("mv /etc/sudoers_new /etc/sudoers") # Enable colors for Pacman (and yay) os.system("sed -i 's/#Color/Color/g' /etc/pacman.conf") if "gdm" in desktop_environment: # Setup GDM to default user to Cinnamon os.system(f"""printf '[User] Language= Session=cinnamon XSession=cinnamon Icon= SystemAccount=false\n\n' > /var/lib/AccountsService/users/{username}""") # Copy last step script to user desktop and remove the remaining files os.system(f"sudo -u {username} sh -c \"mkdir -p ~/Desktop\"") os.system(f"sudo -u {username} sh -c \"cp /tali/steps/post_install_user.py ~/Desktop/\"") os.system(f"sudo -u {username} sh -c \"cp /tali/steps/post_install_system.py ~/Desktop/\"") os.system("rm -rf /tali") print("You can restart your computer now (e.g. " + yellow("shutdown -r now") + ").")
country = "Brazil" keyboard = "br-abnt2" timezone = "America/Sao_Paulo" print_logo() wireless_devices = get_wireless_devices() if (wireless_devices != []): # at least one wireless device was found print("The following Wi-Fi devices were found:") for device in wireless_devices: print(device) else: print("No Wi-Fi device found") print("\nYou're running in " + yellow(f"{get_firmware_interface()}") + " mode") disks = get_disks() print("\nThe following disks were found:") for disk in disks: print(disk) print("\nSetting keyboard layout to " + yellow(keyboard)) os.system(f"loadkeys {keyboard}") print("Setting timezone to " + yellow(timezone)) os.system("timedatectl set-ntp true") os.system(f"timedatectl set-timezone {timezone}")
from utils.colors import cyan, green, yellow from utils.select import select from utils.suggest_partitioning import suggest_partitioning from utils.yes_no_dialog import yes_no_dialog good_to_go = yes_no_dialog( "Did you set your partitions, format them and mount them on " + yellow("/mnt") + "?") if good_to_go: import os print() kernel_packages = select( "Which kernel do you want to install?", dict([("Zen + Mainline (recommended)", "linux-zen linux-zen-headers linux linux-headers"), ("Zen", "linux-zen linux-zen-headers"), ("Mainline", "linux linux-headers")])) os.system( f"pacstrap /mnt base base-devel {kernel_packages} linux-firmware net-tools xdg-user-dirs" ) os.system("pacstrap /mnt python wget") os.system("genfstab -U /mnt >> /mnt/etc/fstab") os.system("cp -r /root/tali /mnt/tali") os.system("cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist") os.system("arch-chroot /mnt python tali/install.py --step 3") else: suggest_partitioning()
from utils.disk_utils import get_disks from utils.print_logo import print_logo from utils.colors import cyan, green, yellow print_logo() wl_devices = get_wireless_devices() if (wl_devices != []): # at least one wireless device was found print("The following Wi-Fi devices were found:") for device in wl_devices: print(device) else: print("No Wi-Fi device found") print("\nYou're running " + yellow(f"{get_firmware_interface()}")) disks = get_disks() print("\nThe following disks were found:") for disk in disks: print(disk) print("\nSetting keyboard layout to " + yellow("br-abnt2")) os.system("loadkeys br-abnt2") print("Writing brazilian mirrors to Pacman's mirrorlist") os.system("pacman -S reflector --noconfirm > /dev/null") os.system( "reflector --country Brazil --age 12 --sort rate --save /etc/pacman.d/mirrorlist"