port client/server to python3

This commit is contained in:
j 2017-06-30 17:38:49 +02:00
parent d222dff214
commit 4781c35643
2 changed files with 5 additions and 5 deletions

View file

@ -33,13 +33,12 @@ class DistributedClient:
def upload(self, oshash, path): def upload(self, oshash, path):
url = '%s/upload/%s' % (self.url, oshash) url = '%s/upload/%s' % (self.url, oshash)
with open(path) as f: with open(path, 'rb') as f:
requests.put(url, f) requests.put(url, f)
def next(self): def next(self):
url = '%s/next' % self.url url = '%s/next' % self.url
r = requests.get(url) data = requests.get(url).json()
data = r.json()
if 'oshash' in data: if 'oshash' in data:
self.encode(data['oshash'], data['cmd'], data['output']) self.encode(data['oshash'], data['cmd'], data['output'])
return True return True

View file

@ -8,9 +8,10 @@ import shutil
import time import time
try: try:
import _thread as thread import _thread as thread
from queue import Queue
except: except:
import thread import thread
from Queue import Queue from Queue import Queue
from threading import Thread from threading import Thread
import ox import ox
@ -74,7 +75,7 @@ class Server(Resource):
def queued(self): 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)
available = filter(lambda oshash: self.is_available(oshash), files) available = list(filter(lambda oshash: self.is_available(oshash), files))
unavailable = list(set(files) - set(available)) unavailable = list(set(files) - set(available))
return available, unavailable return available, unavailable