-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
fireflyc
committed
Aug 4, 2016
0 parents
commit abc49a5
Showing
12 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include README.md requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
PGPIDENT="fireflyc" | ||
PYTHON=python | ||
PIP=pip | ||
PIP_DOUBAN = -i http://pypi.douban.com/simple --trusted-host pypi.douban.com | ||
|
||
all: help | ||
|
||
help: | ||
@echo "dist - distribute project." | ||
@echo "build - Build project using current python." | ||
@echo "test - Run unittests using current python." | ||
@echo "clean - clean" | ||
@echo " clean-pyc - Remove .pyc/__pycache__ files" | ||
@echo " clean-build - Remove setup artifacts." | ||
@echo "release - Make PyPI release." | ||
|
||
clean: clean-pyc clean-build | ||
|
||
release: | ||
python setup.py register sdist bdist_wheel upload --sign --identity="$(PGPIDENT)" | ||
|
||
clean-pyc: | ||
-find . -type f -a \( -name "*.pyc" -o -name "*$$py.class" \) | xargs rm | ||
-find . -type d -name "__pycache__" | xargs rm -r | ||
|
||
clean-build: | ||
rm -rf build/ dist/ .eggs/ *.egg-info/ | ||
|
||
test: | ||
$(PYTHON) setup.py test | ||
|
||
build: | ||
$(PYTHON) setup.py sdist bdist_wheel | ||
|
||
dist_3party: | ||
mkdir -p dist/thirdparty/pipcache | ||
$(PIP) download -r requirements.txt -d ./dist/thirdparty/pipcache $(PIP_DOUBAN) | ||
cp requirements.txt dist/thirdparty/ | ||
echo "pip install --no-index --find-links=pipcache -r requirements.txt">dist/thirdparty/install.sh | ||
|
||
dist: clean build dist_3party |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#Python项目骨架 | ||
建议使用virtualenv构建开发环境 | ||
|
||
* `pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com` 安装依赖 | ||
* `python setup.py develop` link开发环境 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[loggers] | ||
keys=root | ||
|
||
[handlers] | ||
keys=stream_handler | ||
|
||
[formatters] | ||
keys=formatter | ||
|
||
[logger_root] | ||
level=DEBUG | ||
handlers=stream_handler | ||
|
||
[handler_stream_handler] | ||
class=StreamHandler | ||
level=DEBUG | ||
formatter=formatter | ||
args=(sys.stderr,) | ||
|
||
[formatter_formatter] | ||
format=%(asctime)s %(name)-12s %(levelname)-8s %(message)s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[database] | ||
host = localhost | ||
username = root | ||
password = root123 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import ConfigParser | ||
import click | ||
|
||
from python_skeleton.demo import Demo | ||
from python_skeleton.lib import log | ||
|
||
|
||
@click.command() | ||
@click.option("--config-file", required=True, default="/etc/python-skeleton/python-skeleton.conf", help="config file", type=click.Path(exists=True)) | ||
@click.option("--logging-file", required=True, default="/etc/python-skeleton/python-skeleton-logging.conf", help="logging file", type=click.Path(exists=True)) | ||
def main(config_file, logging_file): | ||
log.setup_logging(logging_file) | ||
|
||
config = ConfigParser.ConfigParser() | ||
config.read(config_file) | ||
demo = Demo() | ||
demo.hello("fireflyc") | ||
m | ||
|
||
if __name__ == "__main__": | ||
import os | ||
import sys | ||
|
||
parent_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
etc_path = os.path.join(parent_path, "etc") | ||
sys.argv.append("--config-file=" + os.path.join(etc_path, "python-skeleton.conf")) | ||
sys.argv.append("--logging-file=" + os.path.join(etc_path, "python-skeleton-logging.conf")) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from python_skeleton.lib.log import LogMixin | ||
|
||
|
||
class Demo(LogMixin): | ||
def hello(self, name): | ||
self.logger.info("demo %s", name) | ||
return "Hello, " + name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
click==6.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# coding=utf-8 | ||
from setuptools import setup, find_packages | ||
from pip.req import parse_requirements | ||
|
||
setup( | ||
name="python-skeleton", | ||
version="0.0.1", | ||
description="python skeleton demo", | ||
long_description=open("README.md").read(), | ||
author="fireflyc", | ||
author_email="[email protected]", | ||
url="", | ||
license="", | ||
packages=find_packages(exclude=("tests", "docs", "etc")), | ||
install_requires=[str(ir.req) for ir in parse_requirements("requirements.txt", session=False)], | ||
test_suite="tests", | ||
entry_points=""" | ||
[console_scripts] | ||
python-skeleton=python_skeleton.cli:main | ||
""" | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from unittest import TestCase | ||
from python_skeleton.demo import Demo | ||
|
||
|
||
class DemoTestCase(TestCase): | ||
def setUp(self): | ||
self.demo = Demo() | ||
|
||
def test_hello(self): | ||
assert self.demo.hello("World") == "Hello, World" |