Add osTicket post to finalize_recovery()

This commit is contained in:
2Shirt 2023-08-26 17:53:35 -07:00
parent ce1a4ed723
commit 9ec0a249dd
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 12 additions and 8 deletions

View file

@ -210,6 +210,7 @@ def get_stats(output: str | None = None) -> dict[str, Any]:
def finalize_recovery(state: State, dry_run: bool = True) -> None:
"""Show recovery finalization options and run selected functions."""
options = (
'Post results to osTicket',
'Relocate Backup GPT',
'Zero-fill Gaps',
'Zero-fill Extra Space',
@ -249,6 +250,8 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
if 'GPT' in name and disable_gpt_option:
details['Disabled'] = True
details['Selected'] = False
if 'osTicket' in name:
details['Selected'] = not state.ost.disabled
menu.add_option(name, details)
# Show menu
@ -268,6 +271,10 @@ def finalize_recovery(state: State, dry_run: bool = True) -> None:
# NOTE: This needs to be run last to avoid corrupting/erasing the backup GPT
relocate_backup_gpt(state, dry_run=dry_run)
# osTicket
if menu.options['Post results to osTicket']['Selected']:
state.post_to_osticket()
def is_missing_source_or_destination(state) -> bool:
"""Check if source or destination dissapeared, returns bool."""
@ -378,9 +385,6 @@ def main() -> None:
finalize_recovery(state, dry_run=args['--dry-run'])
break
# osTicket
state.post_to_osticket()
# Save results to log
LOG.info('')
for line in state.generate_report():
@ -761,7 +765,11 @@ def zero_fill_gaps(
LOG.error('zero-fill error: %s, %s', proc.stdout, proc.stderr)
state.notes.add('WARNING: Failed to zero-fill destination')
else:
state.notes.add('NOTE: Zero-filled gaps and extra space on destination.')
msg = (
'NOTE: Zero-filled gaps'
f'{" and extra space on destination." if extend_to_end else "."}'
)
state.notes.add(msg)
if __name__ == '__main__':

View file

@ -577,10 +577,6 @@ class State():
elif percent < 95:
color = 'Normal'
# Ask user
if not cli.ask('Post results to osTicket?'):
return
# Init osTicket if necessary
if not self.ost.ticket_id:
self.ost.init()