Commit 03e02771 authored by labfis's avatar labfis

FIX: Old-Labfis compatibility

parent b1b3b438
......@@ -2,6 +2,9 @@ PYVER := 3
VENV := .venv
INODIR := .ino
PIP3 := pip-3.2
PIP2 := pip-2.7
all: help
help:
......@@ -63,8 +66,8 @@ uninstall: undeploy-logger clean-venv clean-ino
apt-install:
sudo apt-get install python python3 python3-pip supervisor python-pip
sudo pip${PYVER} install virtualenv
sudo pip2 install ino
sudo ${PIP3} install virtualenv
sudo ${PIP2} install ino
setup: apt-install venv
......@@ -86,14 +89,18 @@ clean-venv:
rm -rf ${VENV}
build:
$(eval MODEL := $(shell ${VENV}/bin/python -c "from logger.app import Meteorologger; print(Meteorologger().CFG['ARDUINO']['BOARD_MODEL'])"))
mkdir -p ${INODIR}
mkdir -p ${INODIR}/src/ ${INODIR}/lib/
cp -rf meteorolog/. ${INODIR}/src/
@ echo "Getting board model from settings.yaml"
$(eval MODEL := $(shell cd logger && ../${VENV}/bin/python -c "from app import Meteorologger; print(Meteorologger().CFG['ARDUINO']['BOARD_MODEL'])"))
@ echo "MODEL = ${MODEL}"
cd ${INODIR}/ && ino build -m $(MODEL)
upload:
$(eval MODEL := $(shell ${VENV}/bin/python -c "from logger.app import Meteorologger; print(Meteorologger().CFG['ARDUINO']['BOARD_MODEL'])"))
@ echo "Getting board model from settings.yaml"
$(eval MODEL := $(shell cd logger && ../${VENV}/bin/python -c "from app import Meteorologger; print(Meteorologger().CFG['ARDUINO']['BOARD_MODEL'])"))
@ echo "MODEL = $(MODEL)"
cd ${INODIR}/ && ino upload -m $(MODEL)
serial:
......@@ -117,7 +124,7 @@ undeploy-logger:
sudo ${VENV}/bin/python${PYVER} logger/deploy.py -u
tail-log:
$(eval TMP := $(shell ls -t -I stdout* logger/logs/ | head -n 1))
$(eval TMP := $(shell ls -t -I "pid*|stdout*" logger/logs | head -n 1))
@ echo "Last log file updated: logger/logs/$(TMP)"
@ echo "File size: `du -h logger/logs/$(TMP) | cut -f1`"
@ echo ""
......
......@@ -16,8 +16,6 @@ import serial
import sys
import time
import json
import yaml
import jinja2
from pykwalify.core import Core
......@@ -47,8 +45,8 @@ class Meteorologger:
Call the run() method to start the logging process.
'''
SETTINGS_SCHEMA_FILENAME = 'logger/app/settings_schema.yaml'
SETTINGS_FILENAME = 'settings.yaml'
SETTINGS_SCHEMA_FILENAME = make_current_file_path('settings_schema.yaml')
SETTINGS_FILENAME = make_current_file_path('../../settings.yaml')
DATALOG_DIR = 'data/'
EXECUTION_LOG_PATH = 'logger/logs/'
......@@ -364,9 +362,7 @@ class Meteorologger:
session_datetime = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
try:
os.mkdir(self.DATALOG_DIR)
except FileExistsError:
pass
os.system('mkdir -p {}'.format(self.DATALOG_DIR))
except Exception as e:
print("Unable to create directory data/ to store datalog")
print(e)
......
import os
import subprocess
import sys
import time
PROCESS_NAME = 'meteorologger'
......@@ -37,6 +38,12 @@ def deploy_supervisor():
proc = subprocess.Popen('supervisorctl update', shell=True)
proc.wait()
print('')
time.sleep(2)
proc = subprocess.Popen('supervisorctl status meteorologger', shell=True)
proc.wait()
proc = subprocess.Popen('supervisorctl pid {}'.format(PROCESS_NAME),
shell=True, stdout=subprocess.PIPE)
proc.wait()
......@@ -46,13 +53,10 @@ def deploy_supervisor():
pid = int(pid)
with open(PID_FILENAME, 'w') as f:
f.write(str(pid) + '\n')
print("\nPID: {} (saved at '{}')".format(pid, PID_FILENAME))
print('\n[{} process is running on the background]'
.format(PROCESS_NAME))
f.write(str(pid) + '\n')
except:
print("\nSomething went wrong and the daemon process was NOT created.")
print("\nUnable to save PID={} at '{}'".format(pid, PID_FILENAME))
def undeploy_supervisor():
......
docopt==0.6.2
ipython==3.1.0
Jinja2==2.7.3
MarkupSafe==0.23
pykwalify==1.2.0
pyreadline==2.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment