From 05cdadaf0151177c97ce826fcd4262e0fbb95baf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?dzikie=20dro=C5=BCd=C5=BCe?= Date: Wed, 27 Nov 2013 00:16:20 +0100 Subject: [PATCH] Don't push this commit --- fabfile/fabfile.py | 20 ++++++++++++++++++++ src/.gitmodules | 3 --- src/papiez.sqlite | Bin 72704 -> 72704 bytes src/papiezator/exceptions.py | 5 +++++ src/papiezator/pope_utils.py | 4 +++- src/papiezator/views.py | 13 ++++++------- 6 files changed, 34 insertions(+), 11 deletions(-) delete mode 100644 src/.gitmodules create mode 100644 src/papiezator/exceptions.py diff --git a/fabfile/fabfile.py b/fabfile/fabfile.py index c849f7f..12e4f5b 100644 --- a/fabfile/fabfile.py +++ b/fabfile/fabfile.py @@ -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") + diff --git a/src/.gitmodules b/src/.gitmodules deleted file mode 100644 index acda187..0000000 --- a/src/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "popes"] - path = popes - url = ssh://git@hackerspace.pl/daz/popifier-popes diff --git a/src/papiez.sqlite b/src/papiez.sqlite index 3597173e02839e43579ce39e55de7761b6dbf4a1..45ea40927f399ba0871a28e243e952daa448f506 100644 GIT binary patch delta 280 zcmZqJ!P2mUWr8&0@`*CejLSDBEOF;xVw%aoEXFi*V`DECn5PBW+8P-c8tWPw=^7d+7#Ufanp+tg>X};_ z8=Dw4rcajee#61UJc)sM67%-Wf-G&!nkvk`jD(!S3{o^%&Rb#gZGTM%paF*%m>)79 X0vfQ5SzeCWkrB6@%$pxhmhS)nB9v2J delta 102 zcmZqJ!P2mUWr8&0(up$8j7v8rEOF;xWENv!7Gq}H*!Y);_ZI^am@MY~4k*2yfq6Ug woy~$QtC?9;n0*;1%XuqozU{B+0F-;k!2FQ;Fi>t6Go$T9N2$#ZC(CyL0D?*!djJ3c diff --git a/src/papiezator/exceptions.py b/src/papiezator/exceptions.py new file mode 100644 index 0000000..050230d --- /dev/null +++ b/src/papiezator/exceptions.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +class ENOPopeException(Exception): pass + diff --git a/src/papiezator/pope_utils.py b/src/papiezator/pope_utils.py index d3395f1..29c7314 100644 --- a/src/papiezator/pope_utils.py +++ b/src/papiezator/pope_utils.py @@ -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: diff --git a/src/papiezator/views.py b/src/papiezator/views.py index 55a858b..f9c4ddb 100644 --- a/src/papiezator/views.py +++ b/src/papiezator/views.py @@ -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))