def update_conf(request): print 'inside update_conf' if request.method == "GET": return render(request, "msg.html", {"msg": "This method expects POST only"}) ontologies = request.POST.getlist('ontology') data = request.POST for onto in ontologies: print 'inside the loop' ar2dtool = onto + '-ar2dtool' in data print 'ar2dtool: ' + str(ar2dtool) widoco = onto + '-widoco' in data print 'widoco: ' + str(widoco) oops = onto + '-oops' in data print 'oops: ' + str(oops) print 'will call get_conf' new_conf = get_conf(ar2dtool, widoco, oops) print 'will call update_file' o = 'OnToology' + onto + '/OnToology.cfg' try: print "target_repo <%s> , path <%s> , message <%s> , content <%s>" % ( data['repo'], o, 'OnToology Configuration', new_conf) update_file(data['repo'], o, 'OnToology Configuration', new_conf) except Exception as e: print 'Error in updating the configuration: ' + str(e) return render(request, 'msg.html', {'msg': str(e)}) print 'returned from update_file' print 'will return msg html' return HttpResponseRedirect('/profile')
def update_conf(request): print 'inside update_conf' if request.method == "GET": return render(request, "msg.html", {"msg": "This method expects POST only"}) indic = '-ar2dtool' data = request.POST print 'will go to the loop' for key in data: print 'inside the loop' if indic in key: print 'inside the if' onto = key[:-len(indic)] ar2dtool = data[onto + '-ar2dtool'] print 'ar2dtool: ' + str(ar2dtool) widoco = data[onto + '-widoco'] print 'widoco: ' + str(widoco) oops = data[onto + '-oops'] print 'oops: ' + str(oops) print 'will call get_conf' new_conf = get_conf(ar2dtool, widoco, oops) print 'will call update_file' onto = 'OnToology' + onto + '/OnToology.cfg' try: update_file(data['repo'], onto, 'OnToology Configuration', new_conf) except Exception as e: print 'Error in updating the configuration: ' + str(e) return JsonResponse({ 'status': False, 'error': str(e) }) # return render(request,'msg.html',{'msg': str(e)}) print 'returned from update_file' print 'will return msg html' return JsonResponse({'status': True, 'msg': 'successfully'})
def handle_conf_change(j): """ :param j: :return: """ global logger import autoncore data = j['data'] if j['action'] == 'change_conf': for onto in j['ontologies']: logger.debug('inside the loop') ar2dtool = onto + '-ar2dtool' in data # logger.debug('ar2dtool: ' + str(ar2dtool)) widoco = onto + '-widoco' in data # print 'widoco: ' + str(widoco) oops = onto + '-oops' in data # logger.debug('oops: ' + str(oops) logger.debug('will call get_conf') new_conf = autoncore.get_conf(ar2dtool, widoco, oops) logger.debug('will call update_file') o = 'OnToology' + onto + '/OnToology.cfg' try: logger.debug( "target_repo <%s> , path <%s> , message <%s> , content <%s>" % (j['repo'], o, 'OnToology Configuration', new_conf)) autoncore.update_file(j['repo'], o, 'OnToology Configuration', new_conf) logger.debug( 'configuration is changed for file for ontology: ' + onto) except Exception as e: logger.error('Error in updating the configuration: ' + str(e)) # return render(request, 'msg.html', {'msg': str(e)}) return logger.debug('Configuration changed')
def update_conf(request): print 'inside update_conf' #print request.META['csrfmiddlewaretoken'] if request.method =="GET": return render(request,"msg.html",{"msg":"This method expects POST only"}) indic = '-ar2dtool' data = request.POST print 'will go to the loop' for key in data: print 'inside the loop' if indic in key: print 'inside the if' onto = key[:-len(indic)] ar2dtool = data[onto+'-ar2dtool'] print 'ar2dtool: '+str(ar2dtool) widoco = data[onto+'-widoco'] print 'widoco: '+str(widoco) oops = data[onto+'-oops'] print 'oops: '+str(oops) print 'will call get_conf' new_conf = get_conf(ar2dtool,widoco,oops) print 'will call update_file' onto = 'OnToology'+onto+'/OnToology.cfg' try: update_file(data['repo'],onto,'OnToology Configuration',new_conf) except Exception as e: print 'Error in updating the configuration: '+str(e) return JsonResponse({'status': False,'error': str(e)})#return render(request,'msg.html',{'msg': str(e)}) print 'returned from update_file' print 'will return msg html' return JsonResponse({'status': True,'msg': 'successfully'})