コード例 #1
0
def test():
    gps_interval = request.forms.get('supervisor.gps_interval')
    wake_mode = request.forms.get('supervisor.wake_mode')
    alarm_interval = request.forms.get('supervisor.alarm_interval')
    print(wake_mode)
    print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
    print(gps_interval)
    print('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
    print(alarm_interval)
    updatedProps = compareProperties(request)
    updatedVals = {}
    if (len(updatedProps.keys()) > 0):

        # Writing our configuration file
        with open(CONFIG_FILE, 'r+') as configfile:
            try:
                for key, value in updatedProps.items():
                    print(
                        '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
                    )
                    print('updating', key)
                    print('value', value)
                    print(
                        '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'
                    )
                    #updatedVals.update({key,value})
                    updatedVals[key] = value
                    #replace_key(configFile,key, value)
            finally:
                if configfile is not None:
                    configfile.close()

        if (len(updatedVals) > 0):
            for k, v in updatedVals.items():
                replace_key(CONFIG_FILE, k, v)
    else:
        print('No Config values updated.')

    return template('viewConfig',
                    supervisors=getProperties(SUPERVISOR),
                    imm=getProperties(IMM),
                    hosts=getProperties(HOST))
コード例 #2
0
def index():
    return template('viewConfig',
                    supervisors=getProperties(SUPERVISOR),
                    imm=getProperties(IMM),
                    hosts=getProperties(HOST))