28 lines
No EOL
1 KiB
Python
28 lines
No EOL
1 KiB
Python
"""
|
|
Cancel command for apt-ostree CLI.
|
|
|
|
This module implements the 'cancel' command for cancelling pending transactions
|
|
using the apt-ostree daemon.
|
|
"""
|
|
|
|
import argparse
|
|
from typing import Any
|
|
|
|
def setup_parser(subparsers: argparse._SubParsersAction):
|
|
cancel_parser = subparsers.add_parser('cancel', help='Cancel pending transaction')
|
|
|
|
def run(cli: Any, args: argparse.Namespace) -> int:
|
|
try:
|
|
print("Cancelling pending transaction...")
|
|
result = cli.call_daemon_method('CancelTransaction')
|
|
if result.get('success'):
|
|
print("✓ Transaction cancelled successfully")
|
|
return 0
|
|
else:
|
|
print(f"✗ Transaction cancellation failed: {result.get('error', 'Unknown error')}")
|
|
cli.logger.error(f"Transaction cancellation failed: {result.get('error', 'Unknown error')}")
|
|
return 1
|
|
except Exception as e:
|
|
print(f"Error cancelling transaction: {e}")
|
|
cli.logger.error(f"Error cancelling transaction: {e}")
|
|
return 1 |