(window)
| 31 | |
| 32 | |
| 33 | def update_window(window): |
| 34 | drive_list = [] |
| 35 | particians = psutil.disk_partitions() |
| 36 | all_ok = True |
| 37 | for count, part in enumerate(particians): |
| 38 | mount = part[0] |
| 39 | try: |
| 40 | usage = psutil.disk_usage(mount) |
| 41 | window[('-NAME-', mount)].update(mount) |
| 42 | window[('-PROG-', mount)].update_bar(int(usage.percent)) |
| 43 | window[('-%-', mount)].update(f'{usage.percent}%') |
| 44 | window[('-STATS-', mount)].update(f'{human_size(usage.used)} / {human_size(usage.total)} = {human_size(usage.free)} free') |
| 45 | drive_list.append(str(mount)) |
| 46 | except KeyError as e: # A key error means a new drive was added |
| 47 | all_ok = False |
| 48 | except Exception as e: |
| 49 | pass |
| 50 | all_ok = Globals.drive_list == drive_list and all_ok |
| 51 | Globals.drive_list = drive_list |
| 52 | |
| 53 | return all_ok |
| 54 | |
| 55 | |
| 56 | # ---------------- Create Layout ---------------- |
| 57 | def create_window(location): |
| 58 | layout = [[sg.Text('Drive Status', font='Any 16')]] |
| 59 |
no test coverage detected