def photo_thumbnail(request, owner, nb): storage = Client(domain=settings.MOGILEFS_DOMAIN, trackers=settings.MOGILEFS_TRACKERS) f = storage.read_file( path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb))) return HttpResponse(make_reader(f), content_type='image/jpeg')
def test_read_file(): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, key) fp = client.read_file(key) assert fp is not None assert key == fp.read()
def test_read_file(self): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, key) fp = client.read_file(key) self.assertNotEqual(fp, None) self.assertEqual(key, fp.read())
def test_read_file(self): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, key) fp = client.read_file(key) self.assertNotEqual(fp, None) self.assertEqual(key, fp.read())
def test_read_file(): cl = Client(TEST_NS, HOSTS) cl = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) cl.store_content(key, key) with cl.read_file(key) as fp: assert fp.read() == key
def test_readonly_file(): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, "SPAM") fp = client.read_file(key) try: fp.write("egg") except: pass else: assert False, "operation not permitted to read-only file"
def test_seek_read(): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, "0123456789") fp = client.read_file(key) fp.seek(1) assert fp.tell() == 1 content = fp.read(3) assert content == "123" assert fp.tell() == 4
def test_seek_read(self): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, "0123456789") fp = client.read_file(key) fp.seek(1) self.assertEqual(fp.tell(), 1) content = fp.read(3) assert content == "123" self.assertEqual(fp.tell(), 4)
def test_seek_read(self): client = Client(TEST_NS, HOSTS) key = 'test_file_%s_%s' % (random.random(), time.time()) client.store_content(key, "0123456789") fp = client.read_file(key) fp.seek(1) self.assertEqual(fp.tell(), 1) content = fp.read(3) assert content == "123" self.assertEqual(fp.tell(), 4)
def prepare_photo_files(owner, nb): storage = Client(domain = settings.MOGILEFS_DOMAIN, trackers = settings.MOGILEFS_TRACKERS) #im = Image.open(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s.jpg' % id)) f = storage.read_file(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s,%s.jpg' % (owner, nb))) im = Image.open(f) im.thumbnail((160, 160), Image.ANTIALIAS) tn = storage.new_file(path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb))) im.save(tn, 'JPEG') #sleep(20) photo = Photo.get(owner, nb) photo.ready()
def prepare_photo_files(owner, nb): storage = Client(domain=settings.MOGILEFS_DOMAIN, trackers=settings.MOGILEFS_TRACKERS) #im = Image.open(path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s.jpg' % id)) f = storage.read_file( path.join(settings.UNPROCESSED_PHOTOS_DIR, '%s,%s.jpg' % (owner, nb))) im = Image.open(f) im.thumbnail((160, 160), Image.ANTIALIAS) tn = storage.new_file( path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb))) im.save(tn, 'JPEG') #sleep(20) photo = Photo.get(owner, nb) photo.ready()
def photo_thumbnail(request, owner, nb): storage = Client(domain = settings.MOGILEFS_DOMAIN, trackers = settings.MOGILEFS_TRACKERS) f = storage.read_file(path.join(settings.PROCESSED_PHOTOS_DIR, '%s,%s-160x160.jpg' % (owner, nb))) return HttpResponse(make_reader(f), content_type='image/jpeg')