forked from mdegrazia/piWarmer
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhangar_buddy.py
executable file
·58 lines (52 loc) · 1.72 KB
/
hangar_buddy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Main entry code for HangarBuddy
"""
# !python
#
#
# Author: Mari DeGrazia
# http://az4n6.blogspot.com/
# arizona4n6@gmail.com
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You can view the GNU General Public License at <http://www.gnu.org/licenses/>
#
# Written for Python 2.7
# You will need to "pip install pyserial"
#
# Includes provisions for the basic logic to be run
# for development\testing under Windows or Mac
#
# NOTE: To have this start automatically
#
# 1. sudo vim /etc/rc.local
# 2. Add the following line:
# cd /home/pi/piWarmer
# 3. (OPTIONAL) To have the device update its code automatically
# when connected to wifi, add the following line
# at the bottom of the file:
# /bin/sh /home/pi/piWarmer/update.sh
# 4. Add the following line at the bottom of the file:
# NOTE: if this should be below the optional auto-update line
# python /home/pi/piWarmer/hangar_buddy.py &
import logging
import logging.handlers
import configuration
from lib.logger import Logger
import command_processor
CONFIGURATION = configuration.Configuration()
LOG_LEVEL = logging.INFO
LOGGER = logging.getLogger("heater")
LOGGER.setLevel(LOG_LEVEL)
HANDLER = logging.handlers.RotatingFileHandler(
CONFIGURATION.log_filename, maxBytes=1048576, backupCount=3)
HANDLER.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)-8s %(message)s'))
LOGGER.addHandler(HANDLER)
if __name__ == '__main__':
COMMAND_PROCESSOR = command_processor.CommandProcessor(
CONFIGURATION, Logger(LOGGER))
COMMAND_PROCESSOR.run_hangar_buddy()