mirror of
https://github.com/beetbox/beets.git
synced 2026-01-17 05:34:23 +01:00
first implementation of stats
--HG-- extra : convert_revision : svn%3A41726ec3-264d-0410-9c23-a9f1637257cc/trunk%40147
This commit is contained in:
parent
e2a54e1111
commit
16b36f99a3
2 changed files with 15 additions and 11 deletions
|
|
@ -527,17 +527,6 @@ class ResultIterator(object):
|
|||
|
||||
def __iter__(self): return self
|
||||
|
||||
def count(self):
|
||||
"""Returns the number of matched rows and invalidates the
|
||||
iterator.
|
||||
"""
|
||||
# Apparently, there is no good way to get the number of rows
|
||||
# returned by an sqlite SELECT.
|
||||
num = 0
|
||||
for i in self:
|
||||
num += 1
|
||||
return num
|
||||
|
||||
def next(self):
|
||||
try:
|
||||
row = self.cursor.next()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ from string import Template
|
|||
import beets
|
||||
import traceback
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
||||
DEFAULT_PORT = 6600
|
||||
|
|
@ -178,6 +179,7 @@ class Server(object):
|
|||
"""Block and start listening for connections from clients. An
|
||||
interrupt (^C) closes the server.
|
||||
"""
|
||||
self.startup_time = time.time()
|
||||
try:
|
||||
self.listener = eventlet.api.tcp_listener((self.host, self.port))
|
||||
while True:
|
||||
|
|
@ -831,6 +833,19 @@ class BGServer(Server):
|
|||
]
|
||||
return response
|
||||
|
||||
def cmd_stats(self):
|
||||
# The first three items need to be done more efficiently. The
|
||||
# last three need to be implemented.
|
||||
out = ['artists: ' + str(len(self.lib.artists())),
|
||||
'albums: ' + str(len(self.lib.albums())),
|
||||
'songs: ' + str(len(list(self.lib.items()))),
|
||||
'uptime: ' + str(int(time.time() - self.startup_time)),
|
||||
'playtime: ' + '0',
|
||||
'db_playtime: ' + '0',
|
||||
'db_update: ' + '0',
|
||||
]
|
||||
return SuccessResponse(out)
|
||||
|
||||
# The functions below hook into the half-implementations provided
|
||||
# by the base class. Together, they're enough to implement all
|
||||
# normal playback functionality.
|
||||
|
|
|
|||
Loading…
Reference in a new issue