Mercurial > libervia-backend
comparison sat/bridge/bridge_constructor/constructors/pb/pb_frontend_template.py @ 3243:f2e30aa031e9
bridge (pb): fixed conversions of Failure to BridgeException in non-AIO bridge
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 01 Apr 2020 15:40:29 +0200 |
parents | 559a625a236b |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3242:6d0137022df2 | 3243:f2e30aa031e9 |
---|---|
1 #!/usr/bin/env python3 | 1 #!/usr/bin/env python3 |
2 | 2 |
3 | 3 # SàT communication bridge |
4 # SAT communication bridge | |
5 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) | 4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) |
6 | 5 |
7 # This program is free software: you can redistribute it and/or modify | 6 # This program is free software: you can redistribute it and/or modify |
8 # it under the terms of the GNU Affero General Public License as published by | 7 # it under the terms of the GNU Affero General Public License as published by |
9 # the Free Software Foundation, either version 3 of the License, or | 8 # the Free Software Foundation, either version 3 of the License, or |
62 def __getattr__(self, name): | 61 def __getattr__(self, name): |
63 return partial(self.call, name) | 62 return partial(self.call, name) |
64 | 63 |
65 def _generic_errback(self, err): | 64 def _generic_errback(self, err): |
66 log.error(f"bridge error: {err}") | 65 log.error(f"bridge error: {err}") |
66 | |
67 def _errback(self, failure_, ori_errback): | |
68 """Convert Failure to BridgeException""" | |
69 ori_errback( | |
70 BridgeException( | |
71 name=failure_.type.decode('utf-8'), | |
72 message=str(failure_.value) | |
73 ) | |
74 ) | |
67 | 75 |
68 def remoteCallback(self, result, callback): | 76 def remoteCallback(self, result, callback): |
69 """call callback with argument or None | 77 """call callback with argument or None |
70 | 78 |
71 if result is not None not argument is used, | 79 if result is not None not argument is used, |
157 | 165 |
158 def __init__(self): | 166 def __init__(self): |
159 self.signals_handler = AIOSignalsHandler() | 167 self.signals_handler = AIOSignalsHandler() |
160 | 168 |
161 def _errback(self, failure_): | 169 def _errback(self, failure_): |
170 """Convert Failure to BridgeException""" | |
162 raise BridgeException( | 171 raise BridgeException( |
163 name=failure_.type.decode('utf-8'), | 172 name=failure_.type.decode('utf-8'), |
164 message=str(failure_.value) | 173 message=str(failure_.value) |
165 ) | 174 ) |
166 | 175 |