| 182 | return permissions |
| 183 | |
| 184 | def asyncWrapper(self, func): |
| 185 | def asyncErrorWatcher(func, *args, **kwargs): |
| 186 | try: |
| 187 | result = func(*args, **kwargs) |
| 188 | if result is not None: |
| 189 | self.response(args[0], result) |
| 190 | except Exception as err: |
| 191 | if config.debug: # Allow websocket errors to appear on /Debug |
| 192 | import main |
| 193 | main.DebugHook.handleError() |
| 194 | self.log.error("WebSocket handleRequest error: %s" % Debug.formatException(err)) |
| 195 | self.cmd("error", "Internal error: %s" % Debug.formatException(err, "html")) |
| 196 | |
| 197 | def wrapper(*args, **kwargs): |
| 198 | gevent.spawn(asyncErrorWatcher, func, *args, **kwargs) |
| 199 | return wrapper |
| 200 | |
| 201 | def getCmdFuncName(self, cmd): |
| 202 | func_name = "action" + cmd[0].upper() + cmd[1:] |