|
1 | 1 | import asyncio |
| 2 | +import copyreg |
2 | 3 | import json |
3 | 4 | import sys |
4 | 5 | import logging |
@@ -117,21 +118,23 @@ def find_using_email(self): |
117 | 118 | """ |
118 | 119 | Return the FIRST Cisco Webex Teams person found when searching using an email address |
119 | 120 | """ |
120 | | - for person in self._backend.webex_teams_api.people.list(email=self.email): |
121 | | - self.teams_person = person |
122 | | - return |
123 | | - |
124 | | - raise FailedToFindWebexTeamsPerson(f'Could not find a user using the email address {self.email}') |
| 121 | + try: |
| 122 | + for person in self._backend.webex_teams_api.people.list(email=self.email): |
| 123 | + self.teams_person = person |
| 124 | + return |
| 125 | + except: |
| 126 | + raise FailedToFindWebexTeamsPerson(f'Could not find a user using the email address {self.email}') |
125 | 127 |
|
126 | 128 | def find_using_name(self): |
127 | 129 | """ |
128 | 130 | Return the FIRST Cisco Webex Teams person found when searching using the display name |
129 | 131 | """ |
130 | | - for person in self._backend.webex_teams_api.people.list(displayName=self.displayName): |
131 | | - self.teams_person = person |
132 | | - return |
133 | | - |
134 | | - raise FailedToFindWebexTeamsPerson(f'Could not find the user using the displayName {self.displayName}') |
| 132 | + try: |
| 133 | + for person in self._backend.webex_teams_api.people.list(displayName=self.displayName): |
| 134 | + self.teams_person = person |
| 135 | + return |
| 136 | + except: |
| 137 | + raise FailedToFindWebexTeamsPerson(f'Could not find the user using the displayName {self.displayName}') |
135 | 138 |
|
136 | 139 | def get_using_id(self): |
137 | 140 | """ |
@@ -346,7 +349,7 @@ def invite(self, *args): |
346 | 349 | log.debug("Invite room yet to be implemented") # TODO |
347 | 350 | pass |
348 | 351 |
|
349 | | - def __eq_(self, other): |
| 352 | + def __eq__(self, other): |
350 | 353 | return str(self) == str(other) |
351 | 354 |
|
352 | 355 | def __unicode__(self): |
@@ -393,6 +396,8 @@ def __init__(self, config): |
393 | 396 |
|
394 | 397 | log.debug("Done! I'm connected as {}".format(self.bot_identifier.email)) |
395 | 398 |
|
| 399 | + self._register_identifiers_pickling() |
| 400 | + |
396 | 401 | @property |
397 | 402 | def mode(self): |
398 | 403 | return 'CiscoWebexTeams' |
@@ -666,3 +671,19 @@ def recall_key(self, id, key): |
666 | 671 | :return: Either the value of the key or None if the key is not found |
667 | 672 | """ |
668 | 673 | return self.recall(id).get(key) |
| 674 | + |
| 675 | + @staticmethod |
| 676 | + def _unpickle_identifier(identifier_str): |
| 677 | + return CiscoWebexTeamsBackend.__build_identifier(identifier_str) |
| 678 | + |
| 679 | + @staticmethod |
| 680 | + def _pickle_identifier(identifier): |
| 681 | + return CiscoWebexTeamsBackend._unpickle_identifier, (str(identifier),) |
| 682 | + |
| 683 | + def _register_identifiers_pickling(self): |
| 684 | + """ |
| 685 | + Register identifiers pickling. |
| 686 | + """ |
| 687 | + CiscoWebexTeamsBackend.__build_identifier = self.build_identifier |
| 688 | + for cls in (CiscoWebexTeamsPerson, CiscoWebexTeamsRoomOccupant, CiscoWebexTeamsRoom): |
| 689 | + copyreg.pickle(cls, CiscoWebexTeamsBackend._pickle_identifier, CiscoWebexTeamsBackend._unpickle_identifier) |
0 commit comments