[mod] same for error function

This commit is contained in:
Laurent Peuch 2016-02-18 06:44:12 +01:00
parent 4747366446
commit 24b9883f02
2 changed files with 12 additions and 10 deletions

View File

@ -8,6 +8,7 @@ import shutil
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from .cache import CACHE from .cache import CACHE
from .utils import error
templates = Environment(loader=FileSystemLoader([os.path.realpath(os.path.join(os.getcwd(), "templates")), os.path.join(os.path.split(os.path.realpath(__file__))[0], "templates")])) templates = Environment(loader=FileSystemLoader([os.path.realpath(os.path.join(os.getcwd(), "templates")), os.path.join(os.path.split(os.path.realpath(__file__))[0], "templates")]))
index_template = templates.get_template("index.html") index_template = templates.get_template("index.html")
@ -83,16 +84,6 @@ class Image(object):
return self.name return self.name
def error(test, error_message):
if test:
return
sys.stderr.write(error_message)
sys.stderr.write("\n")
sys.stderr.write("Abort.\n")
sys.exit(1)
def main(): def main():
if os.system("which gm > /dev/null") != 0: if os.system("which gm > /dev/null") != 0:
sys.stderr.write("ERROR: I can't locate the 'gm' binary, I won't be able to resize images, please install the 'graphicsmagick' package.\n") sys.stderr.write("ERROR: I can't locate the 'gm' binary, I won't be able to resize images, please install the 'graphicsmagick' package.\n")

11
prosopopee/utils.py Normal file
View File

@ -0,0 +1,11 @@
import sys
def error(test, error_message):
if test:
return
sys.stderr.write(error_message)
sys.stderr.write("\n")
sys.stderr.write("Abort.\n")
sys.exit(1)