Added update_progress_pane()
* Still a WIP
This commit is contained in:
parent
fa39801523
commit
6ad68c37d4
1 changed files with 66 additions and 9 deletions
|
|
@ -438,13 +438,6 @@ class State():
|
||||||
self.destination = select_path('Destination')
|
self.destination = select_path('Destination')
|
||||||
self.update_top_panes()
|
self.update_top_panes()
|
||||||
|
|
||||||
# Update panes
|
|
||||||
self.panes['Progress'] = tmux.split_window(
|
|
||||||
lines=cfg.ddrescue.TMUX_SIDE_WIDTH,
|
|
||||||
watch_file=f'{self.log_dir}/progress.out',
|
|
||||||
)
|
|
||||||
self.update_progress_pane()
|
|
||||||
|
|
||||||
# Confirmation #1
|
# Confirmation #1
|
||||||
self.confirm_selections(
|
self.confirm_selections(
|
||||||
mode=mode,
|
mode=mode,
|
||||||
|
|
@ -452,6 +445,13 @@ class State():
|
||||||
source_parts=source_parts,
|
source_parts=source_parts,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Update panes
|
||||||
|
self.panes['Progress'] = tmux.split_window(
|
||||||
|
lines=cfg.ddrescue.TMUX_SIDE_WIDTH,
|
||||||
|
watch_file=f'{self.log_dir}/progress.out',
|
||||||
|
)
|
||||||
|
self.update_progress_pane('Idle')
|
||||||
|
|
||||||
# Set working dir
|
# Set working dir
|
||||||
working_dir = get_working_dir(mode, self.destination)
|
working_dir = get_working_dir(mode, self.destination)
|
||||||
|
|
||||||
|
|
@ -476,6 +476,7 @@ class State():
|
||||||
# if cloning and not resuming format destination
|
# if cloning and not resuming format destination
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
|
self.update_progress_pane('Idle')
|
||||||
# Ready for main menu
|
# Ready for main menu
|
||||||
|
|
||||||
def init_tmux(self):
|
def init_tmux(self):
|
||||||
|
|
@ -632,12 +633,54 @@ class State():
|
||||||
std.print_error('Failed to save clone settings')
|
std.print_error('Failed to save clone settings')
|
||||||
raise std.GenericAbort()
|
raise std.GenericAbort()
|
||||||
|
|
||||||
def update_progress_pane(self):
|
def update_progress_pane(self, status):
|
||||||
"""Update progress pane."""
|
"""Update progress pane."""
|
||||||
report = []
|
report = []
|
||||||
|
separator = '─────────────────────'
|
||||||
width = cfg.ddrescue.TMUX_SIDE_WIDTH
|
width = cfg.ddrescue.TMUX_SIDE_WIDTH
|
||||||
|
# TODO: Finish update_progress_pane()
|
||||||
|
|
||||||
#TODO
|
# Status
|
||||||
|
report.append(std.color_string(f'{"Status":^{width}}', 'BLUE'))
|
||||||
|
report.append(f'{status:^{width}}')
|
||||||
|
report.append(separator)
|
||||||
|
|
||||||
|
# Overall progress
|
||||||
|
if self.block_pairs:
|
||||||
|
total_rescued = sum(
|
||||||
|
[pair.map_data.get('rescued', 0) for pair in self.block_pairs],
|
||||||
|
)
|
||||||
|
total_rescued = 400 * 1024**2
|
||||||
|
total_size = sum([pair.size for pair in self.block_pairs])
|
||||||
|
percent = total_rescued / total_size
|
||||||
|
report.append(std.color_string('Overall Progress', 'BLUE'))
|
||||||
|
report.append(
|
||||||
|
std.color_string(
|
||||||
|
['Rescued:', f'{100*total_rescued/total_size:>{width-11}.2f} %'],
|
||||||
|
[None, get_percent_color(percent)],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
report.append(
|
||||||
|
std.color_string(
|
||||||
|
f'{std.bytes_to_string(total_rescued, decimals=2):>{width}}',
|
||||||
|
get_percent_color(percent),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
report.append(separator)
|
||||||
|
|
||||||
|
# Block pair progress
|
||||||
|
for pair in self.block_pairs:
|
||||||
|
report.append(std.color_string(pair.source, 'BLUE'))
|
||||||
|
report.append(f'Pass 1 {"TODO":>{width-7}}')
|
||||||
|
report.append(f'Pass 2 {"TODO":>{width-7}}')
|
||||||
|
report.append(f'Pass 3 {"TODO":>{width-7}}')
|
||||||
|
report.append(' ')
|
||||||
|
|
||||||
|
# EToC
|
||||||
|
if status in ('In Progress', 'NEEDS ATTENTION'):
|
||||||
|
report.append(separator)
|
||||||
|
report.append(std.color_string('Estimated Pass Finish', 'BLUE'))
|
||||||
|
report.append('TODO')
|
||||||
|
|
||||||
# Write to progress file
|
# Write to progress file
|
||||||
out_path = pathlib.Path(f'{self.log_dir}/progress.out')
|
out_path = pathlib.Path(f'{self.log_dir}/progress.out')
|
||||||
|
|
@ -1011,6 +1054,20 @@ def get_partition_separator(name):
|
||||||
return separator
|
return separator
|
||||||
|
|
||||||
|
|
||||||
|
def get_percent_color(percent):
|
||||||
|
"""Get color based on percentage, returns str."""
|
||||||
|
color = 'RED'
|
||||||
|
if percent > 100:
|
||||||
|
color = 'PURPLE'
|
||||||
|
elif percent >= 99:
|
||||||
|
color = 'GREEN'
|
||||||
|
elif percent >= 90:
|
||||||
|
color = 'YELLOW'
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return color
|
||||||
|
|
||||||
|
|
||||||
def get_working_dir(mode, destination):
|
def get_working_dir(mode, destination):
|
||||||
"""Get working directory using mode and destination, returns path."""
|
"""Get working directory using mode and destination, returns path."""
|
||||||
ticket_id = None
|
ticket_id = None
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue