Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
energy
bmon
Commits
fc174ee7
Commit
fc174ee7
authored
Jan 31, 2015
by
Alan Mitchell
Browse files
Moved import_readings script to App script folder.
parent
45258fad
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
bmsapp/scripts/add_sensors.py
bmsapp/scripts/add_sensors.py
+2
-1
bmsapp/scripts/import_readings.py
bmsapp/scripts/import_readings.py
+8
-3
No files found.
bmsapp/scripts/add_sensors.py
View file @
fc174ee7
'''Adds a number of sensors to the system using sensor attributes stored in
a text file.
a text file. This can be less time consuming than using the Admin interface
to add the sensors.
The sensor information must be stored in a text file with the name
'new_sensors.txt' stored in the subdirectory 'files' beneath this script. The
...
...
bmsapp/
readingdb/
scripts/import_readings.py
→
bmsapp/scripts/import_readings.py
View file @
fc174ee7
"""Script to import a file(s) of sensor readings into the reading database.
The script must be called with one command line argument that gives the file
to import or a glob wildcard spec for a set of files. So, examples of running
to import or a glob wildcard spec for a set of files.
NOTE: unlike other scripts in this directory, this script does **not** use the
django-extensions runscript facility. So, examples of running
the script are:
./import_readings.py readings.txt
./import_readings.py *.txt
You can use the 'files' subdirectory to store import files and instead execute:
./import_readings.py files/readings.txt
The script uses the bmsapp.readingdb.bmsdata.BMSdata.import_text_file() method,
so the text file must comply with the format required by that method, which is:
...
...
@@ -28,10 +33,10 @@ import sys, glob
# Add the parent directory to the Python import path
sys
.
path
.
insert
(
0
,
'../'
)
import
bmsdata
import
readingdb.
bmsdata
# Open reading database object
db
=
bmsdata
.
BMSdata
()
db
=
readingdb
.
bmsdata
.
BMSdata
()
for
filename
in
glob
.
glob
(
sys
.
argv
[
1
]):
success_count
,
errors
=
db
.
import_text_file
(
filename
)
...
...
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