|
3 | 3 | import hashlib |
4 | 4 | import json as json_module |
5 | 5 | import logging |
| 6 | +import os |
6 | 7 | import ssl |
7 | 8 | import threading |
8 | 9 | import time |
@@ -298,6 +299,16 @@ def take_control(self, force: bool = False) -> bool: |
298 | 299 | """ |
299 | 300 | active = self._get_active_token() |
300 | 301 |
|
| 302 | + # try to read token from cache file |
| 303 | + token_path = os.path.expanduser('~/.cache/rcs_fr3_token') |
| 304 | + if active.id != "" and self._token.id == "" and os.path.exists(token_path): |
| 305 | + with open(token_path, "r") as f: |
| 306 | + content = f.read() |
| 307 | + content = content.split("/n") |
| 308 | + self._token = Token(content[0], content[1], content[2]) |
| 309 | + |
| 310 | + |
| 311 | + |
301 | 312 | # we already have control |
302 | 313 | if active.id != "" and self._token.id == active.id: |
303 | 314 | _logger.info("Retaken control.") |
@@ -334,12 +345,14 @@ def take_control(self, force: bool = False) -> bool: |
334 | 345 | if event["circle"]: |
335 | 346 | break |
336 | 347 | self._token = Token(str(response["id"]), self._username, response["token"]) |
| 348 | + with open(token_path, "w") as f: |
| 349 | + f.write("/n".join([self._token.id, self._token.owned_by, self._token.token])) |
337 | 350 | _logger.info("Taken control.") |
338 | 351 | return True |
339 | 352 |
|
340 | 353 | def release_control(self) -> None: |
341 | 354 | """ |
342 | | - Explicitly relinquish control of the Desk. This will allow |
| 355 | + Explicitly relinquish cofilentrol of the Desk. This will allow |
343 | 356 | other users to take control or transfer control to the next |
344 | 357 | user if there is an active queue of control requests. |
345 | 358 | """ |
|
0 commit comments