sregistry/main/google_drive/share.py
def share(self, query, share_to):
    '''share will use the client to get an image based on a query, and then
       the link with an email or endpoint (share_to) of choice.
    '''

    images = self._container_query(query, quiet=True)
    if len(images) == 0:
        bot.error('Cannot find a remote image matching %s' %query)
        sys.exit(0)

    image = images[0]

    def callback(request_id, response, exception):
        if exception:
            # Handle error
            print(exception)
        else:
            share_id = response.get('id')
            bot.info('Share to %s complete: %s!' %(share_to, share_id))

    batch = self._service.new_batch_http_request(callback=callback)
    user_permission = {
        'type': 'user',
        'role': 'reader',
        'emailAddress': share_to
    }

    batch.add(self._service.permissions().create(
        fileId=image['id'],
        body=user_permission,
        fields='id',
    ))

    batch.execute()
    return image
def share(self, query, share_to):
    '''share will use the client to get an image based on a query, and then
       the link with an email or endpoint (share_to) of choice.
    '''

    images = self._container_query(query, quiet=True)
    if len(images) == 0:
        bot.error('Cannot find a remote image matching %s' %query)
        sys.exit(0)

    image = images[0]

    def callback(request_id, response, exception):
        if exception:
            # Handle error
            print(exception)
        else:
            share_id = response.get('id')
            bot.info('Share to %s complete: %s!' %(share_to, share_id))

    batch = self._service.new_batch_http_request(callback=callback)
    user_permission = {
        'type': 'user',
        'role': 'reader',
        'emailAddress': share_to
    }

    batch.add(self._service.permissions().create(
        fileId=image['id'],
        body=user_permission,
        fields='id',
    ))

    batch.execute()
    return image
share will use the client to get an image based on a query, and then
       the link with an email or endpoint (share_to) of choice.