greenhouseui/setup.py

42 lines
1.4 KiB
Python
Raw Normal View History

2022-03-29 14:04:51 +00:00
"""Installer"""
2021-05-05 12:17:10 +00:00
import os
import shutil
import stat
from setuptools import setup
from setuptools.command.install import install
2022-03-29 14:04:51 +00:00
NAME = 'Greenhouseui'
2022-04-26 09:09:01 +00:00
VERSION = '5'
2021-05-05 12:17:10 +00:00
AUTHOR = 'Thomas Klaehn'
EMAIL = 'tkl@blackfinn.de'
2022-03-29 14:04:51 +00:00
PACKAGES = ['greenhouseui']
2022-03-30 12:56:24 +00:00
REQUIRES = ['Flask', 'gunicorn', 'matplotlib']
2022-03-29 14:04:51 +00:00
PACKAGE_DATA = {'greenhouseui': ['templates/*', 'static/css/*', 'static/scripts/*']}
2021-05-05 12:17:10 +00:00
SERVICEDIR = "/lib/systemd/system"
2022-03-29 14:04:51 +00:00
DAEMON_START_SCRIPT = os.path.join(SERVICEDIR, 'greenhouseui.service')
2021-05-05 12:17:10 +00:00
2022-03-29 14:04:51 +00:00
LOGFILE = "/var/log/greenhouseui.log"
2021-05-05 12:17:10 +00:00
class Install(install):
2022-03-29 14:04:51 +00:00
"""Installer"""
2021-05-05 12:17:10 +00:00
def run(self):
install.run(self)
os.makedirs(SERVICEDIR, exist_ok=True)
2022-03-29 14:04:51 +00:00
shutil.copyfile('greenhouseui.service', os.path.join(SERVICEDIR, DAEMON_START_SCRIPT))
2021-05-05 12:17:10 +00:00
os.chmod(DAEMON_START_SCRIPT, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH)
try:
2022-03-29 14:04:51 +00:00
open(LOGFILE, 'r', encoding="UTF-8")
2021-05-05 12:17:10 +00:00
except FileNotFoundError:
os.makedirs(os.path.dirname(LOGFILE), exist_ok=True)
2022-03-29 14:04:51 +00:00
open(LOGFILE, 'x', encoding="UTF-8")
2021-05-05 12:17:10 +00:00
os.chmod(LOGFILE, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP |
stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
setup(name=NAME, version=VERSION, long_description=__doc__, author=AUTHOR,
author_email=EMAIL, packages=PACKAGES, include_package_data=True,
package_data=PACKAGE_DATA, zip_safe=False, install_requires=REQUIRES,
cmdclass={'install': Install})