diff --git a/scripts/wk/clone/ddrescue.py b/scripts/wk/clone/ddrescue.py index aafa95c9..a87fc0ed 100644 --- a/scripts/wk/clone/ddrescue.py +++ b/scripts/wk/clone/ddrescue.py @@ -662,12 +662,6 @@ class State(): # Set mode self.mode = set_mode(docopt_args) - # Progress pane - self.panes['Progress'] = tmux.split_window( - lines=cfg.ddrescue.TMUX_SIDE_WIDTH, - watch_file=f'{self.log_dir}/progress.out', - ) - # Select source self.source = select_disk_obj('source', disk_menu, docopt_args['']) self.ui.set_title('Source', self.source.name) @@ -814,7 +808,7 @@ class State(): color = 'Normal' # Ask user - if not std.ask('Post results to osTicket?'): + if not cli.ask('Post results to osTicket?'): return # Init osTicket if necessary @@ -1180,8 +1174,9 @@ class State(): ) # Ticket Details + # TODO: Fixme if self.ost and self.ost.ticket_id: - text = std.color_string( + text = ansi.color_string( [ self.ost.ticket_name, ' ' if self.ost.note else '\n', diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index 38be4584..93f84be0 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -479,7 +479,7 @@ def cpu_stress_tests(state, test_objects, test_mode=False) -> None: # Post results to osTicket if not state.ost.disabled: _failed = test_cooling_obj.failed or test_mprime_obj.failed - std.print_info('Posting results to osTicket...') + cli.print_info('Posting results to osTicket...') state.cpu_max_temp = sensors.cpu_max_temp() state.ost.post_response( hw_osticket.build_report(state.system, 'CPU'), @@ -873,7 +873,7 @@ def run_diags(state, menu, quick_mode=False, test_mode=False) -> None: # Update top_text if state.ost.ticket_id: - state.top_text += std.color_string( + state.top_text += cli.color_string( [f' #{state.ost.ticket_id}', state.ost.ticket_name], [None, 'CYAN'], ) diff --git a/scripts/wk/hw/osticket.py b/scripts/wk/hw/osticket.py index 88648bd8..673532bc 100644 --- a/scripts/wk/hw/osticket.py +++ b/scripts/wk/hw/osticket.py @@ -4,12 +4,13 @@ import logging import re -from wk import std, osticket +from wk import osticket from wk.cfg.hw import ( REGEX_BLOCK_GRAPH, REGEX_SMART_ATTRIBUTES, ) from wk.hw import smart as hw_smart +from wk.ui import cli # STATIC VARIABLES @@ -91,7 +92,7 @@ def build_report(dev, dev_type, num_disk_tests=None): report.pop(-1) # Done - return std.strip_colors('\n'.join(report)) + return cli.strip_colors('\n'.join(report)) def convert_report(original_report, start_index): @@ -101,7 +102,7 @@ def convert_report(original_report, start_index): # Convert report for line in original_report[start_index:]: # Remove colors and leading spaces - line = std.strip_colors(line) + line = cli.strip_colors(line) line = re.sub(r'^\s+', '', line) # Disk I/O Benchmark @@ -152,7 +153,7 @@ def post_disk_results(state, num_disk_tests): return # Post disk results - std.print_info('Posting results to osTicket...') + cli.print_info('Posting results to osTicket...') for disk in state.disks: state.ost.post_response( build_report(disk, 'Disk', num_disk_tests), @@ -181,7 +182,7 @@ def update_checkboxes(state, num_disk_tests): return # Bail if values not confirmed - if not std.ask('Update osTicket checkboxes using the data above?'): + if not cli.ask('Update osTicket checkboxes using the data above?'): return # CPU max temp and pass/fail diff --git a/scripts/wk/os/mac.py b/scripts/wk/os/mac.py index 096e21a3..b5bc107e 100644 --- a/scripts/wk/os/mac.py +++ b/scripts/wk/os/mac.py @@ -8,6 +8,7 @@ import re from wk import std from wk.exe import run_program from wk.hw.disk import Disk +from wk.ui import cli # STATIC VARIABLES @@ -193,13 +194,13 @@ def mount_disk(device_path=None): # Containers if vol.details['Content'] in ('Apple_APFS', 'Apple_CoreStorage'): result += f'{vol.details["Content"].replace("Apple_", "")} container' - report.append(std.color_string(result, 'BLUE')) + report.append(cli.color_string(result, 'BLUE')) continue # Unknown partitions if not vol.details['mountpoint']: result += 'Failed to mount' - report.append(std.color_string(result, 'RED')) + report.append(cli.color_string(result, 'RED')) continue # Volumes diff --git a/scripts/wk/osticket.py b/scripts/wk/osticket.py index 910b69e9..a3f43a8f 100644 --- a/scripts/wk/osticket.py +++ b/scripts/wk/osticket.py @@ -8,9 +8,9 @@ import time import mariadb -from wk import std from wk.cfg.hw import TESTSTATION_FILE from wk.cfg.osticket import SQL, STAFF +from wk.ui import ansi, cli # STATIC_VARIABLES @@ -108,7 +108,7 @@ class osTicket(): for s in self.db_cursor: flag_value = s[0] except mariadb.Error as err_msg: - std.print_error(err_msg) + cli.print_error(err_msg) self.errors = True # Done @@ -132,7 +132,7 @@ class osTicket(): field_data = result[0] except mariadb.Error as err_msg: # Show error and return None - std.print_error(err_msg) + cli.print_error(err_msg) # Done return field_data @@ -153,7 +153,7 @@ class osTicket(): try: self.db_cursor.execute(sql_cmd) except mariadb.Error as err_msg: - std.print_error(err_msg) + cli.print_error(err_msg) self.errors = True def _verify_ticket_id(self): @@ -169,13 +169,13 @@ class osTicket(): prompt = 'Please enter any additional information for this ticket' # Instructions - std.print_standard(prompt) - std.print_info(' (End note with an empty line)') - std.print_standard(' ') + cli.print_standard(prompt) + cli.print_info(' (End note with an empty line)') + cli.print_standard(' ') # Get note while True: - text = std.input_text('> ') + text = cli.input_text('> ') if not text: break lines.append(text.strip()) @@ -217,7 +217,7 @@ class osTicket(): lines.append(f'[Note] {self.note}\n') lines.append(str(response)) response = '\n'.join(lines) - response = std.strip_colors(response) + response = ansi.strip_colors(response) response = response.replace("`", "'").replace("'", "\\'") # Build SQL cmd @@ -256,7 +256,7 @@ class osTicket(): def select_ticket(self): """Set ticket number and name from osTicket DB.""" - std.print_standard('Connecting to osTicket...') + cli.print_standard('Connecting to osTicket...') # Bail if disabled if self.disabled: @@ -267,9 +267,9 @@ class osTicket(): try: self._connect(silent=False) except (mariadb.Error, RuntimeError): - std.print_warning('Failed to connect to osTicket') - if not std.ask('Try again?'): - std.print_standard('Integration disabled for this session') + cli.print_warning('Failed to connect to osTicket') + if not cli.ask('Try again?'): + cli.print_standard('Integration disabled for this session') self.disabled = True return else: @@ -278,14 +278,14 @@ class osTicket(): # Main loop while self.ticket_id is None: - std.print_standard(' ') - _id = std.input_text('Enter ticket number (or leave blank to disable): ') + cli.print_standard(' ') + _id = cli.input_text('Enter ticket number (or leave blank to disable): ') _id = _id.strip() # Nothing entered if not _id: print(' ') - if std.ask('Disable osTicket integration for this session?'): + if cli.ask('Disable osTicket integration for this session?'): self.disabled = True break @@ -298,20 +298,20 @@ class osTicket(): # Invalid ticket selected if _name is None: - std.print_error(f'Ticket #{_id} not found') + cli.print_error(f'Ticket #{_id} not found') continue # Valid ticket selected, lookup subject _subject = self._get_ticket_field(_id, 'subject') # Verify selection - std.print_colored( + cli.print_colored( ['You have selected ticket', f'#{_id}', _name], [None, 'BLUE', None], ) - std.print_colored(f' {_subject}', 'CYAN') - std.print_standard(' ') - if std.ask('Is this correct?'): + cli.print_colored(f' {_subject}', 'CYAN') + cli.print_standard(' ') + if cli.ask('Is this correct?'): self.ticket_id = _id self.ticket_name = _name @@ -333,7 +333,7 @@ class osTicket(): # Compare to current temp current_temp = self._get_flag(FLAG_MAX_TEMP) if str(current_temp).isnumeric() and int(current_temp) > temp: - std.print_warning('Not replacing higher temp in osTicket') + cli.print_warning('Not replacing higher temp in osTicket') self._disconnect() return @@ -373,7 +373,7 @@ class osTicket(): # Bail if flag checkbox set as FAILED if self._get_flag(real_flag_name) == str(FLAG_CODES['Fail']): - std.print_warning( + cli.print_warning( f'Not replacing osTicket {flag_name} checkbox FAILED value', ) self._disconnect()