Don't push this commit

master
daz 2013-11-27 00:16:20 +01:00
parent d84ae580a5
commit 05cdadaf01
6 changed files with 34 additions and 11 deletions

20
fabfile/fabfile.py vendored
View File

@ -15,3 +15,23 @@ def deploy():
with cd(code_dir):
run("git pull")
#run("touch app.wsgi")
def start():
code_dir = '/home/franciszek/papiez_ipsum'
with cd(code_dir):
run("uwsgi --ini uwsgi.ini")
def start_debug():
code_dir = '/home/franciszek/papiez_ipsum/src'
with cd(code_dir):
run("python manage.py runserver 0.0.0.0:8181")
def stop():
code_dir = '/home/franciszek/papiez_ipsum'
with cd(code_dir):
run("uwsgi --stop /tmp/papiez_ipsum.pid")

3
src/.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "popes"]
path = popes
url = ssh://git@hackerspace.pl/daz/popifier-popes

Binary file not shown.

View File

@ -0,0 +1,5 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
class ENOPopeException(Exception): pass

View File

@ -1,9 +1,10 @@
from papiezator.models import Pope, PerfectPope, decimal_places
from papiezator.exceptions import ENOPopeException
from PIL import Image
from decimal import Decimal
PREFIX = "popes"
class ENOPopeException(Exception): pass
def select_best_pope(aspect_ratio):
@ -20,6 +21,7 @@ def select_best_pope(aspect_ratio):
elif not lte:
return gte[0].path
else:
aspect_ratio = Decimal(aspect_ratio)
r_lte = abs(aspect_ratio - lte[0].aspect_ratio) # FIXME:
r_gte = abs(aspect_ratio - gte[0].aspect_ratio)
if r_lte >= r_gte:

View File

@ -3,25 +3,24 @@ from django.shortcuts import render
from django.http import HttpResponse
from PIL import Image
from io import BytesIO # FIXME:
from papiezator.pope_utils import select_best_pope, ENOPopeException
from papiezator.pope_utils import select_best_pope
from papiezator.exceptions import ENOPopeException
from papiezator.models import decimal_places
def index(request):
return render(request,
"papiezator/index.html")
pass
return render(request, "papiezator/index.html")
def conclave(request, width, height):
width, height = int(width), int(height)
if width > 0 and height > 0:
aspect_ratio = width/height
aspect_ratio = round(aspect_ratio, decimal_places)
aspect_ratio = round(width/height, decimal_places)
import ipdb; ipdb.set_trace()
try:
pope = select_best_pope(aspect_ratio)
except ENOPopeException:
return("czarny dym")
return HttpResponse("czarny dym")
im = Image.open(pope.path)
im = im.resize((width, height))