Server Stats: rename feature

This commit is contained in:
albertosottile 2018-07-25 16:19:12 +02:00
parent 14863fbbe7
commit a630860d2e
7 changed files with 25 additions and 21 deletions

View File

@ -53,7 +53,7 @@ DIFFERENT_DURATION_THRESHOLD = 2.5
PROTOCOL_TIMEOUT = 12.5
RECONNECT_RETRIES = 999
SERVER_STATE_INTERVAL = 1
SERVER_LOG_SNAPSHOT_INTERVAL = 3600
SERVER_STATS_SNAPSHOT_INTERVAL = 3600
WARNING_OSD_MESSAGES_LOOP_INTERVAL = 1
AUTOPLAY_DELAY = 3.0
DO_NOT_RESET_POSITION_THRESHOLD = 1.0

View File

@ -434,7 +434,8 @@ de = {
"server-motd-argument": "Pfad zur Datei, von der die Nachricht des Tages geladen wird",
"server-chat-argument": "Should chat be disabled?", # TODO: Translate
"server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # TODO: Translate
"server-maxusernamelength-argument": "Maximum number of charactrs in a username (default is {})", # TODO: Translate
"server-maxusernamelength-argument": "Maximum number of characters in a username (default is {})", # TODO: Translate
"server-stats-db-file-argument": "Enable server stats using the SQLite db file provided", # TODO: Translate
"server-messed-up-motd-unescaped-placeholders": "Die Nachricht des Tages hat unmaskierte Platzhalter. Alle $-Zeichen sollten verdoppelt werden ($$).",
"server-messed-up-motd-too-long": "Die Nachricht des Tages ist zu lang - Maximal {} Zeichen, aktuell {}.",

View File

@ -437,8 +437,9 @@ en = {
"server-disable-ready-argument": "disable readiness feature",
"server-motd-argument": "path to file from which motd will be fetched",
"server-chat-argument": "Should chat be disabled?",
"server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # Default number of characters
"server-maxusernamelength-argument": "Maximum number of charactrs in a username (default is {})",
"server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # Default number of characters
"server-maxusernamelength-argument": "Maximum number of characters in a username (default is {})",
"server-stats-db-file-argument": "Enable server stats using the SQLite db file provided",
"server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).",
"server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.",

View File

@ -437,8 +437,9 @@ it = {
"server-disable-ready-argument": "disabilita la funzionalità \"pronto\"",
"server-motd-argument": "percorso del file da cui verrà letto il messaggio del giorno",
"server-chat-argument": "abilita o disabilita la chat",
"server-chat-maxchars-argument": "Numero massimo di caratteri in un messaggio di chat (default è {})", # Default number of characters
"server-maxusernamelength-argument": "Maximum number of charactrs in a username (default is {})", # TODO: Translate
"server-chat-maxchars-argument": "Numero massimo di caratteri in un messaggio di chat (default è {})", # Default number of characters
"server-maxusernamelength-argument": "Numero massimo di caratteri in un nome utente (default è {})",
"server-stats-db-file-argument": "Abilita la raccolta dei dati statistici nel file SQLite indicato",
"server-messed-up-motd-unescaped-placeholders": "Il messaggio del giorno ha dei caratteri non 'escaped'. Tutti i simboli $ devono essere doppi ($$).",
"server-messed-up-motd-too-long": "Il messaggio del giorno è troppo lungo - numero massimo di caratteri è {}, {} trovati.",

View File

@ -440,9 +440,10 @@ ru = {
"server-motd-argument": "путь к файлу, из которого будет извлекаться MOTD-сообщение",
"server-chat-argument": "Should chat be disabled?", # TODO: Translate
"server-chat-maxchars-argument": "Maximum number of characters in a chat message (default is {})", # TODO: Translate
"server-maxusernamelength-argument": "Maximum number of charactrs in a username (default is {})", # TODO: Translate
"server-messed-up-motd-unescaped-placeholders": "MOTD-сообщение содержит неэкранированные спец.символы. Все знаки $ должны быть продублированы ($$).",
"server-messed-up-motd-too-long": "MOTD-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).",
"server-maxusernamelength-argument": "Maximum number of characters in a username (default is {})", # TODO: Translate
"server-stats-db-file-argument": "Enable server stats using the SQLite db file provided", # TODO: Translate
"server-messed-up-motd-unescaped-placeholders" : "MOTD-сообщение содержит неэкранированные спец.символы. Все знаки $ должны быть продублированы ($$).",
"server-messed-up-motd-too-long" : "MOTD-сообщение слишком длинное: максимальная длина - {} символ(ов), текущая длина - {} символ(ов).",
# Server errors
"unknown-command-server-error": "Неизвестная команда: {}", # message

View File

@ -22,7 +22,7 @@ from syncplay.utils import RoomPasswordProvider, NotControlledRoom, RandomString
class SyncFactory(Factory):
def __init__(self, port='', password='', motdFilePath=None, isolateRooms=False, salt=None,
disableReady=False, disableChat=False, maxChatMessageLength=constants.MAX_CHAT_MESSAGE_LENGTH,
maxUsernameLength=constants.MAX_USERNAME_LENGTH, logDbFile=None):
maxUsernameLength=constants.MAX_USERNAME_LENGTH, statsDbFile=None):
self.isolateRooms = isolateRooms
print(getMessage("welcome-server-notification").format(syncplay.version))
self.port = port
@ -42,12 +42,12 @@ class SyncFactory(Factory):
self._roomManager = RoomManager()
else:
self._roomManager = PublicRoomManager()
if logDbFile is not None:
self.logDbHandle = self._connectToLogDb(logDbFile)
if statsDbFile is not None:
self.statsDbHandle = self._connectToStatsDb(statsDbFile)
logDelay = 5*(int(self.port)%10 + 1)
reactor.callLater(logDelay, self._scheduleVersionSnapshot, self.logDbHandle, self.port)
reactor.callLater(logDelay, self._scheduleClientSnapshot, self.statsDbHandle, self.port)
else:
self.logDbHandle = None
self.statsDbHandle = None
def buildProtocol(self, addr):
return SyncServerProtocol(self)
@ -194,16 +194,16 @@ class SyncFactory(Factory):
else:
watcher.setPlaylistIndex(room.getName(), room.getPlaylistIndex())
def _connectToLogDb(self, dbPath):
def _connectToStatsDb(self, dbPath):
conn = sqlite3.connect(dbPath)
c = conn.cursor()
c.execute('create table if not exists clients_snapshots (snapshot_time integer, port integer, version string, room_index integer, play_status integer)')
conn.commit()
return conn
def _scheduleVersionSnapshot(self, dbHandler, portNumber):
self._versionSnapshotTimer = task.LoopingCall(self._roomManager.runVersionSnapshot, dbHandler, portNumber)
self._versionSnapshotTimer.start(constants.SERVER_LOG_SNAPSHOT_INTERVAL)
def _scheduleClientSnapshot(self, dbHandler, portNumber):
self._clientSnapshotTimer = task.LoopingCall(self._roomManager.runClientSnapshot, dbHandler, portNumber)
self._clientSnapshotTimer.start(constants.SERVER_STATS_SNAPSHOT_INTERVAL)
class RoomManager(object):
@ -280,7 +280,7 @@ class PublicRoomManager(RoomManager):
RoomManager.moveWatcher(self, watcher, room)
watcher.setFile(watcher.getFile())
def runVersionSnapshot(self, dbHandler, portNumber):
def runClientSnapshot(self, dbHandler, portNumber):
snapshotTime = str(int(time.time()))
c = dbHandler.cursor()
for idx, room in enumerate(self._rooms.values()):
@ -597,4 +597,4 @@ class ConfigurationGetter(object):
self._argparser.add_argument('--motd-file', metavar='file', type=str, nargs='?', help=getMessage("server-motd-argument"))
self._argparser.add_argument('--max-chat-message-length', metavar='maxChatMessageLength', type=int, nargs='?', help=getMessage("server-chat-maxchars-argument").format(constants.MAX_CHAT_MESSAGE_LENGTH))
self._argparser.add_argument('--max-username-length', metavar='maxUsernameLength', type=int, nargs='?', help=getMessage("server-maxusernamelength-argument").format(constants.MAX_USERNAME_LENGTH))
self._argparser.add_argument('--log-db-file', metavar='file', type=str, nargs='?', help=getMessage("server-log-db-file-argument"))
self._argparser.add_argument('--stats-db-file', metavar='file', type=str, nargs='?', help=getMessage("server-stats-db-file-argument"))

View File

@ -31,5 +31,5 @@ if __name__ == '__main__':
args.disable_chat,
args.max_chat_message_length,
args.max_username_length,
args.log_db_file))
args.stats_db_file))
reactor.run()