|
28 | 28 |
|
29 | 29 | from unicon.bases.routers.services import BaseService |
30 | 30 | from unicon.core.errors import SubCommandFailure, StateMachineError, \ |
31 | | - CopyBadNetworkError, TimeoutError |
| 31 | + CopyBadNetworkError, TimeoutError, UniconBackendDecodeError |
32 | 32 | from unicon.eal.dialogs import Dialog |
33 | 33 | from unicon.eal.dialogs import Statement |
34 | 34 | from unicon.plugins.generic.statements import ( |
@@ -509,7 +509,7 @@ def call_service(self, target=None, command='', *args, **kwargs): |
509 | 509 | try: |
510 | 510 | sm.go_to(self.start_state, |
511 | 511 | spawn, |
512 | | - context=handle.context, |
| 512 | + context=handle.context, |
513 | 513 | timeout=timeout) |
514 | 514 | except Exception as err: |
515 | 515 | raise SubCommandFailure("Failed to Bring device to Enable State", |
@@ -736,7 +736,7 @@ def call_service(self, command=[], # noqa: C901 |
736 | 736 | self.result = dialog_match.match_output |
737 | 737 | self.result = self.get_service_result() |
738 | 738 | sm.detect_state(con.spawn, con.context) |
739 | | - except StateMachineError: |
| 739 | + except (StateMachineError, UniconBackendDecodeError): |
740 | 740 | raise |
741 | 741 | except Exception as err: |
742 | 742 | raise SubCommandFailure("Command execution failed", err) from err |
@@ -2618,6 +2618,20 @@ def __exit__(self, exc_type, exc_value, exc_tb): |
2618 | 2618 | # do not suppress |
2619 | 2619 | return False |
2620 | 2620 |
|
| 2621 | + def parse(self, *args, **kwargs): |
| 2622 | + abstract_args = kwargs.setdefault('abstract', {}) |
| 2623 | + device = getattr(self.conn, 'device', None) |
| 2624 | + if device: |
| 2625 | + abstract_args.update(dict( |
| 2626 | + os=[device.os, 'linux'], |
| 2627 | + platform=device.platform, |
| 2628 | + model=device.model, |
| 2629 | + pid=device.pid, |
| 2630 | + )) |
| 2631 | + return self.conn.device.parse(*args, **kwargs) |
| 2632 | + else: |
| 2633 | + self.conn.log.warning('No device object, parse method unavailable') |
| 2634 | + |
2621 | 2635 | def __getattr__(self, attr): |
2622 | 2636 | if attr in ('execute', 'sendline', 'send', 'expect'): |
2623 | 2637 | return getattr(self.conn, attr) |
|
0 commit comments