def set_partition_sizes(self): disk = blkinfo.BlkDiskInfo().get_disks({"name": self.install_drive})[0] disk_size = StorageInput(disk.get("size")) boot, root, swap = ( StorageInput("250mib"), StorageInput("30gib"), StorageInput("10gib"), ) test = StorageInput( format_size(boot.raw + root.raw + swap.raw, binary=True)) home_size = StorageInput( format_size(disk_size.raw - test.raw, binary=True)) while True: partitions = d.inputmenu( "Edit GPT partition defaults", height=25, width=50, menu_height=7, choices=[ ("/boot", boot.humanized), ("/", root.humanized), ("/swap", swap.humanized), ("/home", home_size.humanized), ], ) self.simple_msg(str(partitions))
def get_actual_data_from_system() -> dict: """Get data from lsblk. Returns: dict: Dictionary with disk data from system """ myblkd = blkinfo.BlkDiskInfo() filters = {} return myblkd.get_disks(filters)
def set_installation_drive(self): text = "Select a drive to install Arch on" Drive = namedtuple("Drive", ["name", "size", "partitions"]) while True: drives = [ Drive( name=drive.get("name"), size=format_size(int(drive.get("size"))), partitions=drive.get("children"), ) for drive in blkinfo.BlkDiskInfo().get_disks() ] code, drive = d.menu( text, height=10, width=50, menu_height=4, choices=[( drive.name, "{0!r} is {1} and has {2} partitions".format( drive.name, drive.size, len(drive.partitions), ), ) for drive in drives], title="Installation drive selection", ) if code: break reply = d.yes_no( "Install on '%s'?" % drive, height=7, width=40, title="Confirm selection", ) if reply == "no": self.set_installation_drive() else: ArchInstaller.install_drive = drive
def get_block_device_info(): return json.loads(json.dumps(blkinfo.BlkDiskInfo().get_disks()))
filename = wget.download(url) progress = tqdm(filename) for member in progress: progress.set_description(f"downloading {url}") print("file is downloading") elif a == "clear": click.clear() elif a.startswith("rm "): s = a[3:] os.remove(s) print("file removed") elif a.startswith("rmdir "): os.rmdir(a[6:]) print("directory removed!") elif a == "usb-devices": myblkd = blkinfo.BlkDiskInfo() all_my_disks = myblkd.get_disks() for i in all_my_disks: print(i,"\n") elif a == "sleep": while True: time.sleep(1) elif a.startswith("sleep "): time.sleep(a[6:]) elif a.startswith("compile "): os.system('nuitka3 '+a[8:]) elif a == "hardware": hardware() elif a.startswith("pwd"): print(os.getcwd()) elif a == "whoami":
filters = {"tran": "usb"} led_state = 1 def trigger_led(): global led_state led_state = not led_state print(str(int(led_state))) with open('/sys/class/leds/led0/brightness', 'w') as led: led.write(str(int(led_state))) while True: disks = blkinfo.BlkDiskInfo().get_disks(filters) if disks: target_disk_letter = disks[0].get("kname") print('detected{}'.format(target_disk_letter)) subprocess.check_output([ "sudo", "wipefs", "-a", "-f", "/dev/{}".format(target_disk_letter) ]) dd_cmd = [ "sudo", "dd", "if=/dev/zero", "of=/dev/{}".format(target_disk_letter), "bs=512", "count=10240" ] subprocess.check_output(dd_cmd, stderr=subprocess.STDOUT) sectors = int( subprocess.check_output([ 'sudo', 'blockdev', '--getsz', '/dev/{}'.format(target_disk_letter)