Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EMM
meteorolog
Commits
03e02771
Commit
03e02771
authored
Jul 02, 2015
by
labfis
Browse files
FIX: Old-Labfis compatibility
parent
b1b3b438
Changes
4
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
03e02771
...
...
@@ -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
""
...
...
logger/app/main.py
View file @
03e02771
...
...
@@ -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
)
...
...
logger/deploy.py
View file @
03e02771
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
(
"
\n
PID: {} (saved at '{}')"
.
format
(
pid
,
PID_FILENAME
))
print
(
'
\n
[{} process is running on the background]'
.
format
(
PROCESS_NAME
))
f
.
write
(
str
(
pid
)
+
'
\n
'
)
except
:
print
(
"
\n
Something went wrong and the daemon process was NOT created."
)
print
(
"
\n
Unable to save PID={} at '{}'"
.
format
(
pid
,
PID_FILENAME
))
def
undeploy_supervisor
():
...
...
logger/requirements.pip
View file @
03e02771
docopt==0.6.2
ipython==3.1.0
Jinja2==2.7.3
MarkupSafe==0.23
pykwalify==1.2.0
pyreadline==2.0
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment