Fixed names and started updating build_outer_panes
This commit is contained in:
parent
53f0b93a5f
commit
1e195f70fc
1 changed files with 31 additions and 12 deletions
|
|
@ -260,7 +260,11 @@ class DevObj(BaseObj):
|
||||||
"""Set details via lsblk."""
|
"""Set details via lsblk."""
|
||||||
self.type = 'dev'
|
self.type = 'dev'
|
||||||
self.details = get_device_details(self.path)
|
self.details = get_device_details(self.path)
|
||||||
self.name = self.details.get('name', 'UNKNOWN')
|
self.name = '{name} {size} {model} {serial}'.format(
|
||||||
|
name=self.details.get('name', 'UNKNOWN'),
|
||||||
|
size=self.details.get('size', 'UNKNOWN'),
|
||||||
|
model=self.details.get('model', 'UNKNOWN'),
|
||||||
|
serial=self.details.get('serial', 'UNKNOWN'))
|
||||||
self.model = self.details.get('model', 'UNKNOWN')
|
self.model = self.details.get('model', 'UNKNOWN')
|
||||||
self.model_size = self.details.get('size', 'UNKNOWN')
|
self.model_size = self.details.get('size', 'UNKNOWN')
|
||||||
self.size = get_size_in_bytes(self.details.get('size', 'UNKNOWN'))
|
self.size = get_size_in_bytes(self.details.get('size', 'UNKNOWN'))
|
||||||
|
|
@ -298,7 +302,7 @@ class DirObj(BaseObj):
|
||||||
self.type = 'dir'
|
self.type = 'dir'
|
||||||
self.details = get_dir_details(self.path)
|
self.details = get_dir_details(self.path)
|
||||||
self.fstype = self.details.get('fstype', 'UNKNOWN')
|
self.fstype = self.details.get('fstype', 'UNKNOWN')
|
||||||
self.name = self.path
|
self.name = self.path + '/'
|
||||||
self.size = get_size_in_bytes(self.details.get('avail', 'UNKNOWN'))
|
self.size = get_size_in_bytes(self.details.get('avail', 'UNKNOWN'))
|
||||||
self.report = get_dir_report(self.path)
|
self.report = get_dir_report(self.path)
|
||||||
|
|
||||||
|
|
@ -316,7 +320,9 @@ class ImageObj(BaseObj):
|
||||||
self.loop_dev = setup_loopback_device(self.path)
|
self.loop_dev = setup_loopback_device(self.path)
|
||||||
self.details = get_device_details(self.loop_dev)
|
self.details = get_device_details(self.loop_dev)
|
||||||
self.details['model'] = 'ImageFile'
|
self.details['model'] = 'ImageFile'
|
||||||
self.name = self.path[self.path.rfind('/')+1:]
|
self.name = '{name} {size}'.format(
|
||||||
|
name=self.path[self.path.rfind('/')+1:],
|
||||||
|
size=self.details.get('size', 'UNKNOWN'))
|
||||||
self.prefix = '{}_ImageFile'.format(
|
self.prefix = '{}_ImageFile'.format(
|
||||||
self.details.get('size', 'UNKNOWN'))
|
self.details.get('size', 'UNKNOWN'))
|
||||||
self.size = get_size_in_bytes(self.details.get('size', 'UNKNOWN'))
|
self.size = get_size_in_bytes(self.details.get('size', 'UNKNOWN'))
|
||||||
|
|
@ -330,13 +336,25 @@ class ImageObj(BaseObj):
|
||||||
def build_outer_panes(source, dest):
|
def build_outer_panes(source, dest):
|
||||||
"""Build top and side panes."""
|
"""Build top and side panes."""
|
||||||
clear_screen()
|
clear_screen()
|
||||||
|
result = run_program(['tput', 'cols'])
|
||||||
|
width = int(
|
||||||
|
(int(result.stdout.decode().strip()) - SIDE_PANE_WIDTH) / 2) - 2
|
||||||
|
|
||||||
# Top panes
|
# Top panes
|
||||||
|
source_str = source.name
|
||||||
|
if len(source_str) > width:
|
||||||
|
source_str = '{}...'.format(source_str[:width-3])
|
||||||
|
dest_str = dest.name
|
||||||
|
if len(dest_str) > width:
|
||||||
|
if dest.is_dev():
|
||||||
|
dest_str = '{}...'.format(dest_str[:width-3])
|
||||||
|
else:
|
||||||
|
dest_str = '...{}'.format(dest_str[-width+3:])
|
||||||
source_pane = tmux_splitw(
|
source_pane = tmux_splitw(
|
||||||
'-bdvl', '2',
|
'-bdvl', '2',
|
||||||
'-PF', '#D',
|
'-PF', '#D',
|
||||||
'echo-and-hold "{BLUE}Source{CLEAR}\n{text}"'.format(
|
'echo-and-hold "{BLUE}Source{CLEAR}\n{text}"'.format(
|
||||||
text=source['Display Name'],
|
text=source_str,
|
||||||
**COLORS))
|
**COLORS))
|
||||||
tmux_splitw(
|
tmux_splitw(
|
||||||
'-t', source_pane,
|
'-t', source_pane,
|
||||||
|
|
@ -348,15 +366,16 @@ def build_outer_panes(source, dest):
|
||||||
'-t', source_pane,
|
'-t', source_pane,
|
||||||
'-dhp', '50',
|
'-dhp', '50',
|
||||||
'echo-and-hold "{BLUE}Destination{CLEAR}\n{text}"'.format(
|
'echo-and-hold "{BLUE}Destination{CLEAR}\n{text}"'.format(
|
||||||
text=dest['Display Name'],
|
text=dest_str,
|
||||||
**COLORS))
|
**COLORS))
|
||||||
|
|
||||||
# Side pane
|
# Side pane
|
||||||
update_progress(source)
|
# TODO FIX IT
|
||||||
tmux_splitw(
|
#update_progress(source)
|
||||||
'-dhl', '{}'.format(SIDE_PANE_WIDTH),
|
#tmux_splitw(
|
||||||
'watch', '--color', '--no-title', '--interval', '1',
|
# '-dhl', '{}'.format(SIDE_PANE_WIDTH),
|
||||||
'cat', source['Progress Out'])
|
# 'watch', '--color', '--no-title', '--interval', '1',
|
||||||
|
# 'cat', source['Progress Out'])
|
||||||
|
|
||||||
|
|
||||||
def create_path_obj(path):
|
def create_path_obj(path):
|
||||||
|
|
@ -455,8 +474,8 @@ def get_dir_report(dir_path):
|
||||||
'--target', dir_path])
|
'--target', dir_path])
|
||||||
for line in result.stdout.decode().strip().splitlines():
|
for line in result.stdout.decode().strip().splitlines():
|
||||||
if 'FSTYPE' in line:
|
if 'FSTYPE' in line:
|
||||||
output.append('{BLUE}{path:<{width}}{line}{CLEAR}'.format(
|
output.append('{BLUE}{label:<{width}}{line}{CLEAR}'.format(
|
||||||
path=dir_path,
|
label='PATH',
|
||||||
width=width,
|
width=width,
|
||||||
line=line,
|
line=line,
|
||||||
**COLORS))
|
**COLORS))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue