dont include offline files in queue
This commit is contained in:
parent
a85f640705
commit
44bb8aed09
1 changed files with 19 additions and 3 deletions
|
@ -57,10 +57,24 @@ class Server(Resource):
|
||||||
conn.commit()
|
conn.commit()
|
||||||
return files
|
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']
|
site = self.client._config['url']
|
||||||
files = self.client.get_encodes(site)
|
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):
|
def update_status(self, oshash, status):
|
||||||
conn, c = self.client._conn()
|
conn, c = self.client._conn()
|
||||||
|
@ -153,9 +167,11 @@ class Server(Resource):
|
||||||
thread.start_new_thread(self.update, ())
|
thread.start_new_thread(self.update, ())
|
||||||
return self.render_json(request, {'status': True})
|
return self.render_json(request, {'status': True})
|
||||||
elif request.path.startswith('/status'):
|
elif request.path.startswith('/status'):
|
||||||
|
queued, offline = self.queued()
|
||||||
return self.render_json(request, {
|
return self.render_json(request, {
|
||||||
'active': self.active_encodes(),
|
'active': self.active_encodes(),
|
||||||
'queue': self.queued_encodes()
|
'queue': queued,
|
||||||
|
'offline': offline
|
||||||
})
|
})
|
||||||
request.headers['Content-Type'] = 'text/html'
|
request.headers['Content-Type'] = 'text/html'
|
||||||
data = 'pandora_client distributed encoding server'
|
data = 'pandora_client distributed encoding server'
|
||||||
|
|
Loading…
Reference in a new issue