diff --git a/operational b/operational index f5210c4d3b1a08fa02459e4e63196fdc4f2ce583..5c486de8df822518eaadeceed30978ac5aa798a7 100644 --- a/operational +++ b/operational @@ -4,16 +4,6 @@ Time-stamp: <2016-09-08> #+STARTUP: content * current :entry: ** -** 2016-09-08 integrate sanity-check -- update yygame-utils pkg version -- in Makefile - check: just-test -+sanity-check: -+ $(PYTHON) wechat_article_saver_daemon/sanity_check.py - check-coding-style: bootstrap-dev - -- add the template with a dumb check. - ** 2016-09-08 support updating site file, deb scripts etc after project is generated. - the domain in site file could change. - the pkg name could change. @@ -49,6 +39,16 @@ see example ~/.pylintrc ** 2014-05-09 add sphinx support * later :entry: * done :entry: +** DONE 2016-09-08 integrate sanity-check +- update yygame-utils pkg version +- in Makefile + check: just-test ++sanity-check: ++ $(PYTHON) wechat_article_saver_daemon/sanity_check.py + check-coding-style: bootstrap-dev + +- add the template with a dumb check. + ** DONE 2016-06-30 make "lein new python bar" work, without --to-dir . chmod -R +x utils/ diff --git a/project.clj b/project.clj index db2cb6b068b6e5319dfb88d6ef5ff0c8e9f61077..c099b23973905c71256fd831e9192bd1725a6972 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject python/lein-template "0.15.0" +(defproject python/lein-template "0.16.0" :description "lein template for a python project" :repositories [["snapshots" {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots" diff --git a/src/leiningen/new/python.clj b/src/leiningen/new/python.clj index b187ad6dedcc7ee2382e6611833f758efaea6c63..c75c12c8b47726a2efb4c48bbe0a197eb3f24389 100644 --- a/src/leiningen/new/python.clj +++ b/src/leiningen/new/python.clj @@ -67,6 +67,7 @@ package-files ["logger.conf" "configlogger.py" "config.py" + "sanity_check.py" "test_main.py"] post-run-commands ["chmod -R +x utils/ git-hooks/ deb-scripts/" ]] diff --git a/src/leiningen/new/python/Makefile b/src/leiningen/new/python/Makefile index 4ac8cc0e3080c46e29a4b4ea202fbcffb4b712a3..4391fedf322e266bf8ce1fdd7b1d9b3ce8a93c68 100644 --- a/src/leiningen/new/python/Makefile +++ b/src/leiningen/new/python/Makefile @@ -49,6 +49,8 @@ wheel: bootstrap-dev $(PIP) wheel -w wheelhouse -f https://emacsos.com/python/packages/ $(REQUIREMENTS) check: just-test +sanity-check: + $(PYTHON) {{name}}/sanity_check.py check-coding-style: bootstrap-dev $(PEP8) $(PYTHON_MODULES) $(PYLINT) -E $(PYTHON_MODULES) diff --git a/src/leiningen/new/python/requirements.txt b/src/leiningen/new/python/requirements.txt index 70a5508060f79af32145ea6a88ed07a530a6015d..7e4ad277d3fa74105d4a1bb8df3963803430d918 100644 --- a/src/leiningen/new/python/requirements.txt +++ b/src/leiningen/new/python/requirements.txt @@ -1,2 +1,2 @@ -yygame-utils==0.10.0 +yygame-utils==0.15.0 # raven==3.6.1 diff --git a/src/leiningen/new/python/sanity_check.py b/src/leiningen/new/python/sanity_check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb2b6d93164faa824fa1adaf046bd54c8569e1cb --- /dev/null +++ b/src/leiningen/new/python/sanity_check.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# coding=utf-8 + +"""sanity check for {{name}} + +""" + +import sys +import logging + +from yygame.utils import check + +from {{name}}.config import CONF +# from {{name}} import db + +logger = logging.getLogger(__name__) + + +@check +def check_dumb(): + return True + + +# @check +# def check_db(): +# with db.get_cursor() as cur: +# cur.execute(u"""\ +# SELECT 1 +# """) +# return cur.fetchone()[0] == 1 + + +def main(): + results = [ + check_dumb(), + # check_db(), + ] + pass_count = len([x for x in results if x]) + fail_count = len(results) - pass_count + if fail_count: + logger.error("%s checks passed, %s failed.", + pass_count, fail_count) + sys.exit(fail_count) + else: + logger.info("%s checks passed.", pass_count) + + +if __name__ == '__main__': + main()