diff options
Diffstat (limited to 'session.py')
-rw-r--r-- | session.py | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -107,21 +107,27 @@ class Session: def _register_session(self): """Register session in RWA if not in mockup_session mode.""" if not self.mockup_session: - r = requests.post( - REGISTER_URL, - json={ - "port": self.ws_port, - "password": self.password, - "pid": self.vnc_pid, - "trigger_port": self.trigger_port, - "trigger_token": self.trigger_token, - }, - ) + try: + r = requests.post( + REGISTER_URL, + json={ + "port": self.ws_port, + "password": self.password, + "pid": self.vnc_pid, + "trigger_port": self.trigger_port, + "trigger_token": self.trigger_token, + }, + ) + except requests.exceptions.ConnectionError: + raise ConnectionError() logging.info( f"The session has been registered in RWA with status code {r.status_code} and response {r.content.decode()}." ) + if r.status_code != 200: + raise ConnectionError() + self.meta = r.json() self.session_id = self.meta["session_id"] self.web_url = self.meta["url"] |