Commit aaa1e02a authored by Alan Mitchell's avatar Alan Mitchell
Browse files

Added Description field to Periodic Script model.

parent b886ca20
......@@ -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})},
......
# -*- 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'),
),
]
......@@ -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.
......
'''
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()}
......@@ -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()
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