Exemplo n.º 1
0
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')
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
  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())
Exemplo n.º 4
0
    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())
Exemplo n.º 5
0
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
Exemplo n.º 6
0
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"
Exemplo n.º 7
0
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
Exemplo n.º 8
0
  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)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
Arquivo: tasks.py Projeto: savix/jnp3
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()
Exemplo n.º 11
0
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()
Exemplo n.º 12
0
Arquivo: views.py Projeto: savix/jnp3
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')