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
aaa1e02a
Commit
aaa1e02a
authored
Oct 29, 2016
by
Alan Mitchell
Browse files
Added Description field to Periodic Script model.
parent
b886ca20
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
bmsapp/admin.py
bmsapp/admin.py
+1
-1
bmsapp/migrations/0012_periodicscript_description.py
bmsapp/migrations/0012_periodicscript_description.py
+20
-0
bmsapp/models.py
bmsapp/models.py
+3
-0
bmsapp/periodic_scripts/okofen.py
bmsapp/periodic_scripts/okofen.py
+4
-1
bmsapp/scripts/run_periodic_scripts.py
bmsapp/scripts/run_periodic_scripts.py
+1
-1
No files found.
bmsapp/admin.py
View file @
aaa1e02a
...
...
@@ -197,7 +197,7 @@ class AlertRecipientAdmin(admin.ModelAdmin):
@
admin
.
register
(
PeriodicScript
)
class
SensorAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'script_file_name'
,
'script_parameters'
,
'period'
)
list_display
=
(
'script_file_name'
,
'description'
,
'period'
,
'script_parameters'
)
readonly_fields
=
(
'script_results'
,)
formfield_overrides
=
{
models
.
TextField
:
{
'widget'
:
Textarea
(
attrs
=
{
'rows'
:
8
,
'cols'
:
80
})},
...
...
bmsapp/migrations/0012_periodicscript_description.py
0 → 100644
View file @
aaa1e02a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2016-10-30 02:53
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'bmsapp'
,
'0011_auto_20161028_1951'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'periodicscript'
,
name
=
'description'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
80
,
verbose_name
=
b
'Optional Description'
),
),
]
bmsapp/models.py
View file @
aaa1e02a
...
...
@@ -608,6 +608,9 @@ class PeriodicScript(models.Model):
# Name of the script file
script_file_name
=
models
.
CharField
(
'File name of script'
,
max_length
=
50
,
blank
=
False
)
# Optional Description
description
=
models
.
CharField
(
'Optional Description'
,
max_length
=
80
,
blank
=
True
)
# How often the script should be run, in units of seconds.
# Use defined choices; choices must be a multiple of 5 minutes, as that is
# how frequently the main cron procedure runs.
...
...
bmsapp/periodic_scripts/okofen.py
View file @
aaa1e02a
'''
Script to collect sensor readings from an OkoFEN pellet boiler.
'''
import
random
,
time
def
run
(
**
kwargs
):
return
{
'parameters'
:
str
(
kwargs
)}
time
.
sleep
(
random
.
random
()
*
2.0
)
print
kwargs
return
{
'Random Number'
:
random
.
random
()}
bmsapp/scripts/run_periodic_scripts.py
View file @
aaa1e02a
...
...
@@ -137,7 +137,7 @@ class RunScript(threading.Thread):
finally
:
# Store the results back into the model script object so they are
# viewable in the Admin interface and are available for the next call.
self
.
script
.
script_results
=
yaml
.
dump
(
results
)
self
.
script
.
script_results
=
yaml
.
dump
(
results
,
default_flow_style
=
False
)
self
.
script
.
save
()
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