Compare commits
3 Commits
8274c5cd1a
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
85b14a73ed | ||
d0f11e3398 | |||
fda8bcddc8 |
@@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
import site
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
@@ -18,7 +20,8 @@ heat_pin = 26
|
|||||||
|
|
||||||
heat_state = False
|
heat_state = False
|
||||||
|
|
||||||
CONFIG_FILE = "/etc/greenhouse/greenhouse.json"
|
PACKAGE_PATH = site.getsitepackages()[0]
|
||||||
|
CONFIG_FILE = os.path.join(PACKAGE_PATH, "greenhouse/config/greenhouse.json")
|
||||||
|
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
@@ -28,8 +31,8 @@ log_level = logging.INFO
|
|||||||
LOG_FILE = "/var/log/greenhouse.log"
|
LOG_FILE = "/var/log/greenhouse.log"
|
||||||
LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
LOG_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
||||||
|
|
||||||
logging.basicConfig(format=LOG_FORMAT, level=log_level, filename=LOG_FILE)
|
# logging.basicConfig(format=LOG_FORMAT, level=log_level, filename=LOG_FILE)
|
||||||
#logging.basicConfig(format=LOG_FORMAT, level=log_level)
|
logging.basicConfig(format=LOG_FORMAT, level=log_level)
|
||||||
log = logging.getLogger('greenhouse')
|
log = logging.getLogger('greenhouse')
|
||||||
|
|
||||||
class Heat(Thread):
|
class Heat(Thread):
|
||||||
|
15
setup.py
15
setup.py
@@ -1,6 +1,3 @@
|
|||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
NAME = 'Greenhouse'
|
NAME = 'Greenhouse'
|
||||||
@@ -11,14 +8,8 @@ PACKAGES = ['greenhouse']
|
|||||||
REQUIRES = ['Flask', 'w1thermsensor', 'RPi.GPIO']
|
REQUIRES = ['Flask', 'w1thermsensor', 'RPi.GPIO']
|
||||||
CONFIG_FOLDER = '/etc/greenhouse'
|
CONFIG_FOLDER = '/etc/greenhouse'
|
||||||
CONFIG_FILE = 'greenhouse.json'
|
CONFIG_FILE = 'greenhouse.json'
|
||||||
|
PACKAGE_DATA = {'greenhouse': ['templates/*', 'static/css/*', 'static/scripts/*', 'config/*']}
|
||||||
|
|
||||||
setup(name=NAME, version=VERSION, long_description=__doc__, author=AUTHOR, author_email=EMAIL,
|
setup(name=NAME, version=VERSION, long_description=__doc__, author=AUTHOR, author_email=EMAIL,
|
||||||
packages=PACKAGES, include_package_data=True, zip_safe=False, install_requires=REQUIRES)
|
packages=PACKAGES, include_package_data=True, package_data=PACKAGE_DATA, zip_safe=False,
|
||||||
|
install_requires=REQUIRES)
|
||||||
if sys.argv[1] == 'install':
|
|
||||||
try:
|
|
||||||
os.makedirs(CONFIG_FOLDER)
|
|
||||||
shutil.copyfile(CONFIG_FILE, os.path.join(CONFIG_FOLDER, CONFIG_FILE))
|
|
||||||
except FileExistsError:
|
|
||||||
#FIXME: handle overwriting the config file
|
|
||||||
pass
|
|
||||||
|
Reference in New Issue
Block a user