~hristoast/mousikofidi

c0b57cb50588058596dadf479acf752356bb5872 — Hristos N. Triantafillou 1 year, 7 months ago f1c87dc
Add a script to the setuptools installer

This is simply a convenience wrapper around `flask` and `uwsgi` but I
think it makes sense to add it.`
2 files changed, 44 insertions(+), 0 deletions(-)

A example/mousikofidi
M setup.py
A example/mousikofidi => example/mousikofidi +43 -0
@@ 0,0 1,43 @@
#!/bin/sh

arg="${1}"

if [ "${arg}" = "--help" ] || [ "${arg}" = "-h" ]; then
    cat <<EOF
usage: mousikofidi [-h] [-d] [any flask or uWSGI options]

Run MousikóFídi via Flask or uWSGI.

optional arguments:
  -h, --help            show this help message and exit

Options:
  -d, --dev             Run MousikóFídi via the Flask dev server.  Not
                        recommended for production.

Aside from the above, any other options passed will be provided to
'flask' or 'uwsgi', consult their documentation for more information
about what's available.
EOF
    exit 1
fi

if [ "${arg}" = "--dev" ] || [ "${arg}" = "-d" ]; then
    if [ -f $(which uwsgi >/dev/null 2>/dev/null) ]; then
        FLASK_APP=mousikofidi FLASK_ENV=development flask run
    else
        echo "ERROR: The `flask` executable could not be found!  Exiting..."
        exit 1
    fi
fi

if ! [ -f $(which uwsgi >/dev/null 2>/dev/null) ]; then
    echo "ERROR: The `uwsgi` executable could not be found!  Exiting..."
    exit 1
fi

if [ -f ~/.config/fidi/uwsgi.ini ]; then
    uwsgi --ini ~/.config/fidi/uwsgi.ini "${@}"
else
    uwsgi "${@}"
fi

M setup.py => setup.py +1 -0
@@ 58,4 58,5 @@ setup(
    ],
    install_requires=["Flask==1.0.3", "mutagen==1.42.0", "uWSGI==2.0.18"],
    python_requires=">=3.4",
    scripts=["example/mousikofidi"],
)