Skip to content

Commit

Permalink
First Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
elicity committed Dec 30, 2017
0 parents commit ad899ea
Show file tree
Hide file tree
Showing 20 changed files with 271 additions and 0 deletions.
106 changes: 106 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

.idea

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

# 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
.static_storage/
.media/
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.6
MAINTAINER geod
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
#ENTRYPOINT ["python"]
CMD ["python", "w4156/app.py"]
5 changes: 5 additions & 0 deletions bin/changemac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

NEWMAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
echo $NEWMAC
sudo ifconfig en0 ether $NEWMAC
1 change: 1 addition & 0 deletions bin/docker_bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run -i -t --rm --entrypoint /bin/bash w4156
3 changes: 3 additions & 0 deletions bin/docker_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker build -t w4156:latest .
11 changes: 11 additions & 0 deletions bin/docker_connect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

CONTAINERID=`docker ps | grep w4156 | cut -d" " -f1`

if [ -z ${CONTAINERID} ];
then
echo "Container not found"
else
docker exec -it $CONTAINERID bash
fi

3 changes: 3 additions & 0 deletions bin/docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker run -d -p 5000:5000 w4156
11 changes: 11 additions & 0 deletions bin/docker_stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

CONTAINERID=`docker ps | grep w4156 | cut -d" " -f1`

if [ -z ${CONTAINERID} ];
then
echo "Container not found"
else
docker stop $CONTAINERID
fi

5 changes: 5 additions & 0 deletions bin/docker_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

#NOTE - this runs the tests within the docker container

docker run --interactive --tty w4156 'bin/tests_run.sh'
5 changes: 5 additions & 0 deletions bin/tests_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Note - runs tests outside of the docker container

python -m unittest
6 changes: 6 additions & 0 deletions bin/venv_activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

source ./env/bin/activate

export PYTHONPATH=`pwd`
echo PYTHONPATH:$PYTHONPATH
3 changes: 3 additions & 0 deletions bin/venv_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

virtualenv --python=python3.6 env
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
boto3==1.5.7
botocore==1.8.21
docutils==0.14
jmespath==0.9.3
python-dateutil==2.6.1
s3transfer==0.1.12
six==1.11.0
wheel==0.24.0
Flask==0.12.2
Empty file added tests/__init__.py
Empty file.
51 changes: 51 additions & 0 deletions tests/test_boto.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# import boto3
#
# print('creating dynamodb resource')
#
# dynamodb = boto3.resource(
# 'dynamodb',
# endpoint_url='http://localhost:8000',
# region_name='dummy_region',
# aws_access_key_id='dummy_access_key',
# aws_secret_access_key='dummy_secret_key',
# verify=False)
#
# print('got resource:', dynamodb)
#
# print('adding table')
#
# result = dynamodb.create_table(
# TableName='foo',
# KeySchema=[
# {
# 'AttributeName': 'from_email',
# 'KeyType': 'HASH' # Partition key
# },
# {
# 'AttributeName': 'raw_id',
# 'KeyType': 'RANGE' # Sort key
# },
# ],
# AttributeDefinitions=[
# {
# 'AttributeName': 'from_email',
# 'AttributeType': 'S'
# },
# {
# 'AttributeName': 'raw_id',
# 'AttributeType': 'N'
# },
# ],
# ProvisionedThroughput={
# 'ReadCapacityUnits': 10,
# 'WriteCapacityUnits': 10
# }
# )
#
# print('created table:', result)
#
# print('getting table')
#
# table = dynamodb.Table('foo')
#
# print('got table:', table)
25 changes: 25 additions & 0 deletions tests/test_first_flask_level_test_goes_here.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import os
import w4156.app as flaskapp
import unittest
import tempfile


class FlaskTestCase(unittest.TestCase):

def setUp(self):
self.db_fd, flaskapp.app.config['DATABASE'] = tempfile.mkstemp()
flaskapp.app.testing = True
self.app = flaskapp.app.test_client()
# with w4156.app.app_context():
# w4156.init_db()

def test_hello(self):
rv = self.app.get('/')
self.assertEqual(rv.data, "Hello, World!")

def tearDown(self):
os.close(self.db_fd)
os.unlink(flaskapp.app.config['DATABASE'])

if __name__ == '__main__':
unittest.main()
10 changes: 10 additions & 0 deletions tests/test_first_unit_test_goes_here.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import unittest


class MyTestCase(unittest.TestCase):
def test_something(self):
self.assertEqual(True, False)


if __name__ == '__main__':
unittest.main()
Empty file added w4156/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions w4156/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from flask import Flask
app = Flask(__name__)


@app.route('/')
def hello_world():
return 'Hello, World!'

if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
Empty file.

0 comments on commit ad899ea

Please sign in to comment.