Пример #1
0
    def get_uaid(self, uaid):
        # type: (str) -> Dict[str, Any]
        """Get the database record for the UAID

        :raises:
            :exc:`ItemNotFound` if there is no record for this UAID.
            :exc:`ProvisionedThroughputExceededException` if dynamodb table
            exceeds throughput.

        """
        try:
            item = self.table.get_item(
                Key={'uaid': hasher(uaid)},
                ConsistentRead=True,
            )

            if item.get('ResponseMetadata').get('HTTPStatusCode') != 200:
                raise ItemNotFound('uaid not found')
            item = item.get('Item')
            if item is None:
                raise ItemNotFound("uaid not found")
            if item.keys() == ['uaid']:
                # Incomplete record, drop it.
                self.drop_user(uaid)
                raise ItemNotFound("uaid not found")
            # Mobile users do not check in after initial registration.
            # DO NOT EXPIRE THEM.
            return item
        except Boto3Error:  # pragma: nocover
            # We trap JSONResponseError because Moto returns text instead of
            # JSON when looking up values in empty tables. We re-throw the
            # correct ItemNotFound exception
            raise ItemNotFound("uaid not found")
Пример #2
0
 def _delete_channel(self, uaid, chid):
     # type: (uuid.UUID, uuid.UUID) -> None
     if not self.db.message.unregister_channel(uaid.hex, chid.hex):
         raise ItemNotFound("ChannelID not found")
     self.log.info("Unregister",
                   client_info=self._client_info,
                   channel_id=chid.hex,
                   uaid_hash=hasher(uaid.hex))
Пример #3
0
 def throw_item(*args, **kwargs):
     raise ItemNotFound("Not found")
Пример #4
0
 def throw():
     raise ItemNotFound()
Пример #5
0
 def _delete_uaid(self, uaid):
     self.log.debug(format="Dropping User",
                    code=101,
                    uaid_hash=hasher(uaid.hex))
     if not self.db.router.drop_user(uaid.hex):
         raise ItemNotFound("UAID not found")