Loading ccserver/ccserver.py +2 −3 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ class CCServer(object): if login in self._connected: client = self._connected[login] tags['con'] = client.get_uptime() try: tags.update(client.connection.call('get_tags', tuple(requested_tags))) Loading @@ -137,9 +138,7 @@ class CCServer(object): logging.error('Error while calling get_tags on ' '%s: %s' % (client.login, err)) else: tags['status'] = 'online' else: tags['status'] = 'offline' tags['con'] = 'offline' # Apply all user specified tags: tags.update(conf['tags']) Loading ccserver/client.py +11 −14 Original line number Diff line number Diff line #!/usr/bin/env python #coding=utf8 from datetime import datetime class CCClient(object): ''' Represent a single client connected to the server. Loading @@ -20,20 +22,15 @@ class CCClient(object): # The connection of the client (public attribute): self.connection = connection def get_tags(self, tags=None): ''' Get the tags of the object. # The date of connection of the client: self._connection_date = datetime.now() :param tags: the list of tags to fetch, or None for all def get_uptime(self): ''' Get the uptime of the client connection in seconds. # 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: uptime of the client ''' return tags dt = datetime.now() - self._connection_date return dt.seconds + dt.days * 86400 Loading
ccserver/ccserver.py +2 −3 Original line number Diff line number Diff line Loading @@ -130,6 +130,7 @@ class CCServer(object): if login in self._connected: client = self._connected[login] tags['con'] = client.get_uptime() try: tags.update(client.connection.call('get_tags', tuple(requested_tags))) Loading @@ -137,9 +138,7 @@ class CCServer(object): logging.error('Error while calling get_tags on ' '%s: %s' % (client.login, err)) else: tags['status'] = 'online' else: tags['status'] = 'offline' tags['con'] = 'offline' # Apply all user specified tags: tags.update(conf['tags']) Loading
ccserver/client.py +11 −14 Original line number Diff line number Diff line #!/usr/bin/env python #coding=utf8 from datetime import datetime class CCClient(object): ''' Represent a single client connected to the server. Loading @@ -20,20 +22,15 @@ class CCClient(object): # The connection of the client (public attribute): self.connection = connection def get_tags(self, tags=None): ''' Get the tags of the object. # The date of connection of the client: self._connection_date = datetime.now() :param tags: the list of tags to fetch, or None for all def get_uptime(self): ''' Get the uptime of the client connection in seconds. # 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: uptime of the client ''' return tags dt = datetime.now() - self._connection_date return dt.seconds + dt.days * 86400