Commit dee18c21 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Remove obsolete migration scripts.

parent 8ff48bb0
# -*- coding: utf-8 -*-
""" NAME
migrate-list-070
SYNOPSIS
Migrate list from version 0.6.4 to 0.7.0.
DESCRIPTION
In version 0.7.0, the reporting tool have been redesign.
This tool allow to migrate the list
OPTIONS
-h, --help
Display the help and exit.
EXAMPLE
> cd ...tev/plugin_event/scripts
> ./run -S test_event script migrate-list-070.py
AUTHOR
R. Le Gac -- Feb 2017
"""
import re
import sys
from gluon.storage import Storage
from gluon.tools import PluginManager
def fix_dbname(s):
s = (s.replace("domains.", "")
.replace("fundings.", "")
.replace("history.note", "history_note")
.replace("history.data.", "")
.replace("history.", "")
.replace("objects.note", "objects_note")
.replace("objects.", "")
.replace("object_categories.", "object_categories_")
.replace("people.note", "people_note")
.replace("people.", "")
.replace("people_categories.", "people_categories_")
.replace("projects.", "")
.replace("teams.", ""))
return s
if __name__ == "__main__":
event.Event.register_sources()
event.Core.define_tables(db, T)
event.Report.define_tables(db, T)
rex_id_events = re.compile("\.id_events *={1,2} *(\d+)")
sources = PluginManager("event").event.sources.keys()
sources.sort()
for row in db(db.lists.id > 0).select():
rep = raw_input("Migrate '%s' [y/N]: " % row.name)
if rep.lower() != "y":
continue
# copy and fix
list2 = Storage(name=row.name,
title=row.title,
definition=row.definition,
id_events=1,
group_field=row.group_field,
sorters=row.sorters,
columns=row.columns,
summary_group=True,
summary_all=True)
list2.columns = list2.columns.replace("dbfield", "dataIndex")
list2.columns = fix_dbname(list2.columns)
list2.group_field = fix_dbname(list2.group_field)
list2.sorters = [fix_dbname(el) for el in list2.sorters]
# find the event identifier
m = rex_id_events.search(row.conditions)
if m:
list2.id_events = int(m.group(1))
# setup the source
print "\tSelect the source: "
for i in xrange(len(sources)):
print "\t%5i %s" % (i, sources[i])
rep = raw_input("\tEnter a value [i/N]: ")
if not rep.isdigit():
continue
list2.source = sources[int(rep)]
# create
db.lists2[0] = list2
db.commit()
print "\tNew %s list created" % row.name
sys.exit(0)
\ No newline at end of file
# -*- coding: utf-8 -*-
""" NAME
migrate-metric2d-070
SYNOPSIS
Migrate metric2d from version 0.6.4 to 0.7.0.
DESCRIPTION
In version 0.7.0, the reporting tool have been redesign.
This tool allow to migrate the metric2d.
OPTIONS
-h, --help
Display the help and exit.
EXAMPLE
> cd ...tev/plugin_event/scripts
> ./run -S test_event script migrate-metric2d-070.py
AUTHOR
R. Le Gac -- 2017
"""
import re
import sys
from gluon.storage import Storage
from gluon.tools import PluginManager
def fix_dbname(s):
s = (s.replace("domains.", "")
.replace("fundings.", "")
.replace("history.note", "history_note")
.replace("history.data.", "")
.replace("history.", "")
.replace("objects.note", "objects_note")
.replace("objects.", "")
.replace("object_categories.", "object_categories_")
.replace("people.note", "people_note")
.replace("people.", "")
.replace("people_categories.", "people_categories_")
.replace("projects.", "")
.replace("teams.", ""))
return s
if __name__ == "__main__":
event.Event.register_sources()
event.Core.define_tables(db, T)
event.Report.define_tables(db, T)
rex_id_events = re.compile("\.id_events *={1,2} *(\d+)")
sources = PluginManager("event").event.sources.keys()
sources.sort()
for row in db(db.metrics2d.id > 0).select():
rep = raw_input("Migrate '%s' [y/N]: " % row.name)
if rep.lower() != "y":
continue
print row
# copy and fix
metric2d = Storage(name=row.name,
title=row.title,
definition=row.definition,
id_events=1,
group_field_x=fix_dbname(row.group_field_x),
group_field_y=fix_dbname(row.group_field_y),
metric_field_z=fix_dbname(row.metric_field_z),
aggregate_func_z=row.aggregation_z)
# find the event identifier
m = rex_id_events.search(row.conditions)
if m:
metric2d.id_events = int(m.group(1))
# setup the source
print "\tSelect the source: "
for i in xrange(len(sources)):
print "\t%5i %s" % (i, sources[i])
rep = raw_input("\tEnter a value [i/N]: ")
if not rep.isdigit():
continue
metric2d.source = sources[int(rep)]
# create
db.metrics2d2[0] = metric2d
db.commit()
print "\tNew %s list created" % row.name
sys.exit(0)
\ No newline at end of file
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