Commit a28a1fe2 authored by Alan Mitchell's avatar Alan Mitchell

Added two Python 2 to 3 upgrade scripts.

Finds links in Alerts and replaces the select_sensor parameter if it
is a timeseries plot.
Removes fixed width in Custom Reports plots and fixes links.
parent 4050d50c
#!/usr/local/bin/python3.7
'''Upgrades the Alert Condition objects from the Python 2.7
version to BMON to the Python 3.7 version (which uses Bootstrap 4).
The upgrade relates to a change in the name of the drop-down control
that selects mutliple sensors.
'''
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bmon.settings")
django.setup()
from bmsapp.models import AlertCondition
ct = 0
for cx in AlertCondition.objects.all():
msg = cx.alert_message
if 'select_chart=2' in msg:
msg_new = msg.replace('select_sensor=', 'select_sensor_multi=')
cx.alert_message = msg_new
cx.save()
print(cx.alert_message)
ct += 1
print(ct)
#!/usr/local/bin/python3.7
'''Upgrades the Custom Reports model objects from the old Python 2.7
version of BMON to the Python 3.7 version (which also utilizes the
Bootstrap 4 framework, which causes most of the need to the following
changes.)
'''
import os
import django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bmon.settings")
django.setup()
from bmsapp.models import CustomReport
for rpt in CustomReport.objects.all():
txt = rpt.markdown_text
txt_new = txt.replace(' style="width: 930px"', '')
new_lines = []
for lin in txt_new.splitlines():
if 'select_chart=2' in lin:
new_lin = lin.replace('select_sensor=', 'select_sensor_multi=')
else:
new_lin = lin
new_lines.append(new_lin)
rpt.markdown_text = '\n'.join(new_lines)
rpt.save()
print(rpt.markdown_text)
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