Skip to content

Commit

Permalink
add more
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaopeng163 committed Feb 14, 2018
1 parent b37ddcf commit e701cdb
Show file tree
Hide file tree
Showing 53 changed files with 2,259 additions and 0 deletions.
40 changes: 40 additions & 0 deletions chapter8/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version ">= 1.6.0"

boxes = [
{
:name => "docker-ee-manager",
:eth1 => "192.168.205.50",
:mem => "3072",
:cpu => "1"
},
{
:name => "docker-ee-worker",
:eth1 => "192.168.205.60",
:mem => "3072",
:cpu => "1"
}

]

Vagrant.configure(2) do |config|

config.vm.box = "centos/7"
boxes.each do |opts|
config.vm.define opts[:name] do |config|
config.vm.hostname = opts[:name]
config.vm.provider "vmware_fusion" do |v|
v.vmx["memsize"] = opts[:mem]
v.vmx["numvcpus"] = opts[:cpu]
end
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", opts[:mem]]
v.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
end
config.vm.network :private_network, ip: opts[:eth1]
end
end
config.vm.synced_folder "./labs", "/home/vagrant/labs"
end
16 changes: 16 additions & 0 deletions chapter8/labs/flask-skeleton/.coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[run]
source = skeleton
omit =
skeleton/tests/*
*/__init__.py

[report]
exclude_lines =
def __repr__
def __str__
def parse_args
pragma: no cover
raise NotImplementedError
if __name__ == .__main__.:

ignore_errors = True
91 changes: 91 additions & 0 deletions chapter8/labs/flask-skeleton/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env

# virtualenv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

*.sqlite
62 changes: 62 additions & 0 deletions chapter8/labs/flask-skeleton/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
variables:
GIT_SSL_NO_VERIFY: "1"

stages:
- test
- build
- deploy

pep8:
stage: test
image: python:2.7
script:
- pip install tox
- tox -e pep8
tags:
- python27

unittest-py27:
stage: test
image: python:2.7
script:
- pip install tox
- tox -e py27
tags:
- python27

unittest-py34:
stage: test
image: python:3.4
script:
- pip install tox
- tox -e py34
tags:
- python34

sphnix:
stage: test
image: python:2.7
script:
- pip install tox
- tox -e docs
tags:
- python27

build:
stage: build
tags:
- shell
script:
- docker build -t skeleton .
only:
- master

deploy:
stage: deploy
tags:
- shell
script:
- scripts/deploy.sh
- export
only:
- master
18 changes: 18 additions & 0 deletions chapter8/labs/flask-skeleton/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Hacking Guide

## Code style

Step 1: Read http://www.python.org/dev/peps/pep-0008/

Step 2: Read http://www.python.org/dev/peps/pep-0008/ again

Step 3: Read on

## Running Tests

Run tox

```
$ cd skeleton
$ tox
```
9 changes: 9 additions & 0 deletions chapter8/labs/flask-skeleton/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:2.7

MAINTAINER Peng Xiao <[email protected]>

COPY . /skeleton
WORKDIR /skeleton
RUN pip install -r requirements.txt
EXPOSE 5050
ENTRYPOINT ["scripts/dev.sh"]
8 changes: 8 additions & 0 deletions chapter8/labs/flask-skeleton/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The MIT License (MIT)
Copyright (c) 2016 Michael Herman

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58 changes: 58 additions & 0 deletions chapter8/labs/flask-skeleton/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[![build status](https://gitlab-demo.com/Demo/flask-skeleton/badges/master/build.svg)](https://gitlab-demo.com/Demo/flask-skeleton/commits/master)
[![coverage report](https://gitlab-demo.com/Demo/flask-skeleton/badges/master/coverage.svg)](https://gitlab-demo.com/Demo/flask-skeleton/commits/master)


# Flask Skeleton

Flask starter project...

## Quick Start

### Basics

1. Activate a virtualenv
1. Install the requirements

### Set Environment Variables

Update *skeleton/server/config.py*, and then run:

```sh
$ export APP_SETTINGS="skeleton.server.config.DevelopmentConfig"
```

or

```sh
$ export APP_SETTINGS="skeleton.server.config.ProductionConfig"
```

### Create DB

```sh
$ python manage.py create_db
$ python manage.py db init
$ python manage.py db migrate
$ python manage.py create_admin
$ python manage.py create_data
```

### Run the Application

```sh
$ python manage.py runserver
```

So access the application at the address [http://localhost:5000/](http://localhost:5000/)

> Want to specify a different port?
> ```sh
> $ python manage.py runserver -h 0.0.0.0 -p 8080
> ```
### Testing1
```
$ tox
```
Loading

0 comments on commit e701cdb

Please sign in to comment.