Skip to content
client.py 1008 B
Newer Older
Antoine Millet's avatar
Antoine Millet committed
#!/usr/bin/env python
#coding=utf8

class CCClient(object):
    '''
    Represent a single client connected to the server.
    '''

    def __init__(self, login, role, server, connection):

        # The login of the client:
        self._login = login

        # The role of the client:
        self._role = role

        # The server binded to this client:
        self._server = server

        # The connection of the client (public attribute):
        self.connection = connection

    def get_tags(self, tags=None):
        '''
        Get the tags of the object.

        :param tags: the list of tags to fetch, or None for all
        '''

        # Get the tags from the server
        tags = self.connection.call('get_tags', tags)
        # Add the static tags:
        tags['a'] = self._login
        tags['hv'] = self._login
        tags['role'] = self._role
        # Update it with the locally defined tags:
        tags.update(self._server.conf.show(self._login)['tags'])

        return tags