def pre_edit_cfg():
    if os.path.exists('./config_log.txt'):
        try:
            print('opening config log')
            f = open('./config_log.txt')
            lines = f.readlines()
            cfg.BATCH_SIZE = int(lines[0].strip('\n'))

            cfg.TRUNCATES_MEAN = float(lines[1].strip('\n'))
            cfg.TRUNCATES_STTDEV = float(lines[2].strip('\n'))
            cfg.BIAS = float(lines[3].strip('\n'))

            cfg.LOSS_PRINT_STEPS = int(lines[4].strip('\n'))

            cfg.TRAIN_STEP = float(lines[5].strip('\n'))
            cfg.EPOCHS = int(lines[6].strip('\n'))

            cfg.SAVE_STEPS = int(lines[7].strip('\n'))
            cfg.IS_RESTORE = lines[8].strip('\n') == 'True'
            cfg.SAVED_WEIGHT_STEPS = int(lines[9].strip('\n'))
            cfg.TEST_MODE = lines[10].strip('\n')
        except Exception as e:
            print(Exception,':', e)
            print('Config value error.Please resset.')
    cfg.print_setting()
            cfg.SAVE_STEPS = int(lines[7].strip('\n'))
            cfg.IS_RESTORE = lines[8].strip('\n') == 'True'
            cfg.SAVED_WEIGHT_STEPS = int(lines[9].strip('\n'))
            cfg.TEST_MODE = lines[10].strip('\n')
        except Exception as e:
            print(Exception,':', e)
            print('Config value error.Please resset.')
    cfg.print_setting()

if __name__ == '__main__':
    is_start = False
    is_pause = False
    print('\nIf you need help,please enter \'help\'')
    command = input('press enter to continue or reset\n')
    if command == 'reset':
        cfg.print_setting()
        try:
            os.remove('./config_log.txt')
        except IOError as e:
            pass
    else:
        pre_edit_cfg()
    while True:
        command = input("Enter your command: ")
        if command == 'help':
            print('help,start,pause,resume,stop,savew,set,exit')
        elif command == 'weight_file':
            for wf in os.walk('./weight'):
                print(wf)
        elif command == 'start' and (not is_start):
            dgnet = val5.diguinet()