Commit 03e02771 authored by labfis's avatar labfis
Browse files

FIX: Old-Labfis compatibility

parent b1b3b438
...@@ -2,6 +2,9 @@ PYVER := 3 ...@@ -2,6 +2,9 @@ PYVER := 3
VENV := .venv VENV := .venv
INODIR := .ino INODIR := .ino
PIP3 := pip-3.2
PIP2 := pip-2.7
all: help all: help
help: help:
...@@ -63,8 +66,8 @@ uninstall: undeploy-logger clean-venv clean-ino ...@@ -63,8 +66,8 @@ uninstall: undeploy-logger clean-venv clean-ino
apt-install: apt-install:
sudo apt-get install python python3 python3-pip supervisor python-pip sudo apt-get install python python3 python3-pip supervisor python-pip
sudo pip${PYVER} install virtualenv sudo ${PIP3} install virtualenv
sudo pip2 install ino sudo ${PIP2} install ino
setup: apt-install venv setup: apt-install venv
...@@ -86,14 +89,18 @@ clean-venv: ...@@ -86,14 +89,18 @@ clean-venv:
rm -rf ${VENV} rm -rf ${VENV}
build: 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}
mkdir -p ${INODIR}/src/ ${INODIR}/lib/ mkdir -p ${INODIR}/src/ ${INODIR}/lib/
cp -rf meteorolog/. ${INODIR}/src/ 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) cd ${INODIR}/ && ino build -m $(MODEL)
upload: 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) cd ${INODIR}/ && ino upload -m $(MODEL)
serial: serial:
...@@ -117,7 +124,7 @@ undeploy-logger: ...@@ -117,7 +124,7 @@ undeploy-logger:
sudo ${VENV}/bin/python${PYVER} logger/deploy.py -u sudo ${VENV}/bin/python${PYVER} logger/deploy.py -u
tail-log: 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 "Last log file updated: logger/logs/$(TMP)"
@ echo "File size: `du -h logger/logs/$(TMP) | cut -f1`" @ echo "File size: `du -h logger/logs/$(TMP) | cut -f1`"
@ echo "" @ echo ""
......
...@@ -16,8 +16,6 @@ import serial ...@@ -16,8 +16,6 @@ import serial
import sys import sys
import time import time
import json import json
import yaml
import jinja2
from pykwalify.core import Core from pykwalify.core import Core
...@@ -47,8 +45,8 @@ class Meteorologger: ...@@ -47,8 +45,8 @@ class Meteorologger:
Call the run() method to start the logging process. Call the run() method to start the logging process.
''' '''
SETTINGS_SCHEMA_FILENAME = 'logger/app/settings_schema.yaml' SETTINGS_SCHEMA_FILENAME = make_current_file_path('settings_schema.yaml')
SETTINGS_FILENAME = 'settings.yaml' SETTINGS_FILENAME = make_current_file_path('../../settings.yaml')
DATALOG_DIR = 'data/' DATALOG_DIR = 'data/'
EXECUTION_LOG_PATH = 'logger/logs/' EXECUTION_LOG_PATH = 'logger/logs/'
...@@ -364,9 +362,7 @@ class Meteorologger: ...@@ -364,9 +362,7 @@ class Meteorologger:
session_datetime = datetime.now().strftime('%Y-%m-%d-%H-%M-%S') session_datetime = datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
try: try:
os.mkdir(self.DATALOG_DIR) os.system('mkdir -p {}'.format(self.DATALOG_DIR))
except FileExistsError:
pass
except Exception as e: except Exception as e:
print("Unable to create directory data/ to store datalog") print("Unable to create directory data/ to store datalog")
print(e) print(e)
......
import os import os
import subprocess import subprocess
import sys import sys
import time
PROCESS_NAME = 'meteorologger' PROCESS_NAME = 'meteorologger'
...@@ -37,6 +38,12 @@ def deploy_supervisor(): ...@@ -37,6 +38,12 @@ def deploy_supervisor():
proc = subprocess.Popen('supervisorctl update', shell=True) proc = subprocess.Popen('supervisorctl update', shell=True)
proc.wait() proc.wait()
print('')
time.sleep(2)
proc = subprocess.Popen('supervisorctl status meteorologger', shell=True)
proc.wait()
proc = subprocess.Popen('supervisorctl pid {}'.format(PROCESS_NAME), proc = subprocess.Popen('supervisorctl pid {}'.format(PROCESS_NAME),
shell=True, stdout=subprocess.PIPE) shell=True, stdout=subprocess.PIPE)
proc.wait() proc.wait()
...@@ -47,12 +54,9 @@ def deploy_supervisor(): ...@@ -47,12 +54,9 @@ def deploy_supervisor():
with open(PID_FILENAME, 'w') as f: with open(PID_FILENAME, 'w') as f:
f.write(str(pid) + '\n') f.write(str(pid) + '\n')
print("\nPID: {} (saved at '{}')".format(pid, PID_FILENAME))
print('\n[{} process is running on the background]'
.format(PROCESS_NAME))
except: 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(): def undeploy_supervisor():
......
docopt==0.6.2 docopt==0.6.2
ipython==3.1.0 ipython==3.1.0
Jinja2==2.7.3
MarkupSafe==0.23 MarkupSafe==0.23
pykwalify==1.2.0 pykwalify==1.2.0
pyreadline==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