Remove Persona since it was shut down. :(
[xonotic/xonstat.git] / xonstat / models / server.py
1 """
2 Models related to servers.
3 """
4
5 from datetime import datetime as dt
6
7 from xonstat.models.mixins import FuzzyDateMixin, EpochMixin
8
9
10 class Server(FuzzyDateMixin, EpochMixin):
11     """
12     A Xonotic server, identifiable by name and (when there's a conflict) hashkey.
13     """
14
15     def __init__(self, name=None, hashkey=None, ip_addr=None, elo_ind=None):
16         self.name = name
17         self.hashkey = hashkey
18         self.ip_addr = ip_addr
19         self.elo_ind = elo_ind if elo_ind is not None else True
20         self.create_dt = dt.utcnow()
21
22     def __repr__(self):
23         return "<Server({}, {})>".format(self.server_id, self.name.encode('utf-8'))
24
25     def to_dict(self):
26         return {
27             'server_id': self.server_id,
28             'name': self.name,
29             'ip_addr': self.ip_addr,
30             'location': self.location,
31         }