Skip to content

Commit

Permalink
Adds mvp functionality (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Allen Leis authored Oct 26, 2020
1 parent 7419749 commit 4822898
Show file tree
Hide file tree
Showing 25 changed files with 1,864 additions and 13 deletions.
124 changes: 124 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Local development
local-setup.sh
driver.py
ignore.py

# OS trash
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-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/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/build/
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# 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/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
5 changes: 5 additions & 0 deletions DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# btrdbextras

This package contains additional enhancements and features to interact with the BTrDB database and Pingthings platform.

Please see the full documentation at: [https://btrdbextras.readthedocs.io/en/latest/](https://btrdbextras.readthedocs.io/en/latest/).
11 changes: 11 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Copyright (c) 2020 PingThing Inc, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 changes: 22 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include *.md
include *.rst
include *.txt
include *.yml
include *.yaml
include *.cfg
include Makefile
include MANIFEST.in

graft docs
prune docs/build

graft tests

graft btrdbextras

global-exclude __pycache__
global-exclude *.py[co]
global-exclude .ipynb_checkpoints
global-exclude .DS_Store
global-exclude .env
global-exclude .coverage.*
62 changes: 62 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Shell to use with Make
SHELL := /bin/bash

# Set important Paths
PROJECT := btrdbextras
LOCALPATH := $(CURDIR)/$(PROJECT)

# Sphinx configuration
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXBUILDDIR = docs/build
SPHINXSOURCEDIR = docs/source

# Export targets not associated with files
.PHONY: test grpc

# Clean build files
clean:
find . -name "*.pyc" -print0 | xargs -0 rm -rf
find . -name "__pycache__" -print0 | xargs -0 rm -rf
find . -name ".DS_Store" -print0 | xargs -0 rm -rf
-rm -rf docs/build
-rm -rf htmlcov
-rm -rf .pytest_cache
-rm -rf .coverage
-rm -rf build
-rm -rf dist
-rm -rf $(PROJECT).egg-info
-rm -rf .eggs
-rm -rf site
-rm -rf docs/build
-rm -rf platform-builds meta.yaml

# Generate new grpc code
grpc:
@echo Generating files:
python -m grpc_tools.protoc -I btrdbextras/eventproc/protobuff --python_out=btrdbextras/eventproc/protobuff --grpc_python_out=btrdbextras/eventproc/protobuff btrdbextras/eventproc/protobuff/api.proto
@echo
@echo Fixing import statements:
sed -i'.bak' 's/api_pb2 as api__pb2/btrdbextras.eventproc.protobuff.api_pb2 as api__pb2/' btrdbextras/eventproc/protobuff/api_pb2_grpc.py


# Targets for testing
test:
python setup.py test

# Build the universal wheel and source distribution
build:
python setup.py sdist bdist_wheel

# Install the package from source
install:
python setup.py install

# Deploy to PyPI
deploy:
# python setup.py register
twine upload dist/* --verbose

# Build html version of docs
html:
$(SPHINXBUILD) -b html $(SPHINXOPTS) $(SPHINXSOURCEDIR) $(SPHINXBUILDDIR)
3 changes: 3 additions & 0 deletions btrdbextras/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .conn import Connection

__version__ = "v5.11.2"
42 changes: 42 additions & 0 deletions btrdbextras/conn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# eventproc.conn
# Connection related objects
#
# Author: PingThings
# Created:
#
# For license information, see LICENSE.txt
# ID: conn.py [] allen@pingthings.io $

"""
Connection related objects
"""

##########################################################################
## Imports
##########################################################################

import os

##########################################################################
## Classes
##########################################################################

class Connection():

def __init__(self, endpoint=os.environ.get("BTRDB_ENDPOINTS"), apikey=os.environ.get("BTRDB_API_KEY")):
if endpoint is None:
raise Exception("invalid endpoint or BTRDB_ENDPOINTS env variable not set")

if apikey is None:
raise Exception("invalid api key or BTRDB_API_KEY env variable not set")

self._endpoint = endpoint
self._apikey = apikey

@property
def apikey(self):
return self._apikey

@property
def endpoint(self):
return self._endpoint
3 changes: 3 additions & 0 deletions btrdbextras/eventproc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .eventproc import hooks, list_handlers, register, deregister

__all__ = ['hooks', 'list_handlers', 'register', 'deregister']
Loading

0 comments on commit 4822898

Please sign in to comment.