#!/usr/bin/python2

from edge.webserver.sysconf import ph
from edge.webserver.sysconf.uiconf.pipeline import PipelineUiconf


def _main():
    terms_info = PipelineUiconf.load_conf()
    pid_type_list = map(lambda x: (x['id'], x['type']), terms_info)
    for term_pid, term_type in pid_type_list:
        vs_uimod = ph.UiMod(term_pid, 'videosource', '0')
        vs_uiconf = vs_uimod.load_conf(default=None)
        if vs_uiconf is None:
            continue

        if 'haltaction' in vs_uiconf['ro']:
            vs_uiconf['ro'].pop('haltaction')
            vs_uimod.save_conf(vs_uiconf)

        if term_type == PipelineUiconf.PTYPE_TERM_RADAR:
            location_uimod = ph.UiMod(term_pid, ph.UI_TYPE_LOCATION, '0')
            location_uiconf = location_uimod.load_conf()
            if 'haltaction' in location_uiconf['ro']:
                location_uiconf['ro'].pop('haltaction')
                location_uimod.save_conf(location_uiconf)


if __name__ == '__main__':
    _main()
