dont include offline files in queue

This commit is contained in:
j 2014-04-02 17:52:50 +02:00
parent a85f640705
commit 44bb8aed09

View file

@ -57,10 +57,24 @@ class Server(Resource):
conn.commit()
return files
def queued_encodes(self):
def is_available(self, oshash):
info = self.client.info(oshash)
if info and not 'error' in info:
for path in self.client.path(oshash):
if os.path.exists(path):
return True
return False
def queued(self):
site = self.client._config['url']
files = self.client.get_encodes(site)
return files
available = filter(lambda oshash: self.is_available(oshash), files)
unavailable = list(set(files) - set(available))
return available, unavailable
def queued_encodes(self):
available, unavailable = self.queued()
return available
def update_status(self, oshash, status):
conn, c = self.client._conn()
@ -153,9 +167,11 @@ class Server(Resource):
thread.start_new_thread(self.update, ())
return self.render_json(request, {'status': True})
elif request.path.startswith('/status'):
queued, offline = self.queued()
return self.render_json(request, {
'active': self.active_encodes(),
'queue': self.queued_encodes()
'queue': queued,
'offline': offline
})
request.headers['Content-Type'] = 'text/html'
data = 'pandora_client distributed encoding server'