Skip to content

Commit

Permalink
BeerBot 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jfri3d committed Aug 1, 2019
0 parents commit fbdbe0b
Show file tree
Hide file tree
Showing 19 changed files with 946 additions and 0 deletions.
173 changes: 173 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@

# Created by https://www.gitignore.io/api/python,pycharm,visualstudiocode
# Edit at https://www.gitignore.io/?templates=python,pycharm,visualstudiocode

### PyCharm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/

# CMake
cmake-build-*/

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### PyCharm Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721

# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr

### Python ###
# 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/
pip-wheel-metadata/
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/

# 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/

### Python Patch ###
.venv/

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
.history

# End of https://www.gitignore.io/api/python,pycharm,visualstudiocode
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# BeerBot

This repository is the central location for all things related to the beloved **BeerBot**.

Tread _carefully_ since this is an extremely important project within [KI labs](https://ki-labs.com/).

![alt text](assets/logo.png "BeerBot")

# Features

BeerBot is a slackbot capable of the following:

- checking beer (or bottled beverages) in the fridge
- identify and analyze whether bottled beverages are *cold*
- automatically alert when beer is running low

# Processing Pipeline

![alt text](assets/BeerBot.png "Pipeline")
Empty file added analysis/__init__.py
Empty file.
36 changes: 36 additions & 0 deletions analysis/file_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from __future__ import print_function

import os
from time import gmtime


def get_images(source):
path = "{}/{}".format(os.getenv("DATA_DIR"), source)
return [os.path.join(path, basename) for basename in os.listdir(path)]


def build_image_path(source, timestamp, extension="png"):
return "{}/{}/{}.{}".format(os.getenv("DATA_DIR"), source, timestamp, extension)


def get_latest_image(source):
paths = get_images(source)
latest_file = max(paths, key=os.path.getctime)
return latest_file


def get_latest_images(source, num_images):
paths = get_images(source)
paths = sorted(paths, key=os.path.getctime, reverse=True)
return paths[0:num_images]


def get_current_inventory():
path = "{}/inventory.txt".format(os.getenv("DATA_DIR"))
with open(path, "r") as f:
lines = f.read().splitlines()
if not lines:
return None
last_line = lines[-1]
timestamp, count = last_line.split(",")
return gmtime(int(timestamp)), int(count)
Loading

0 comments on commit fbdbe0b

Please sign in to comment.