def delete_in_field(): if "mail" in session: try: if request.method == 'POST': # print ("2") data_dict = request.form.to_dict() #print mydict message = str(request.form['command']) field = str(request.form['fields']) #print message,field if message != "": handler = data_handler() handler_data = str(handler.delete_in_field(message, field)) #print handler_data api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.infield.delete(data=handler_data) #print products return '%s' % products else: return render_template("dashboard.html") else: render_template("dashboard.html") except: render_template("dashboard.html") else: return redirect(url_for('login'))
def delete_popular(): if "mail" in session: try: if request.method == 'POST': #print ("2") data_dict = request.form.to_dict() print "++++++++++" print(request) print data_dict print "++++++++++" message = str(request.form['command']) print message try: field = str(request.form['fields']) except: field = "" print message print field print message, field if (field == ""): try: flds = str(request.form['data']) #print flds flds = flds.split("--->") #print flds field = flds[0] except: print "send is pressed with empty value" if message != "": handler = data_handler() handler_data = (handler.delete_popular_product( message, field)) print handler_data api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = str( api.popularproduct.delete(data=handler_data)) #print products #print products res_popular = response_handler() final_message = str(res_popular.delPopular(products)) return '%s' % final_message else: return render_template("dashboard.html") else: return render_template("dashboard.html") except: return render_template("dashboard.html") #data_object = DAO.DataDAO() #data_object.save_message(processed_text) else: return redirect(url_for('login'))
def add_in_field(): if "mail" in session: try: #print("alok") if request.method == 'POST': data_dict = request.form.to_dict() #print mydict field = str(request.form['fields']) #keylist = data_dict.keys() message = str(data_dict["command"]) ''' values=[] for val in keylist: if(val[0:6]=="alltxt"): values.append(int(val[6:])) values=sorted(values) #print values string="" for param in values: #print param #print str(mydict["mytext"+str(param)]) string=string+str(data_dict["alltxt"+str(param)])+"_" field=string[:-2] #print field input_text_list=[] for param in values: input_text_list.append(str(data_dict["alltxt"+str(param)])) string="" for items in input_text_list: if items!="": string=string+str(items)+"_" field=string[:-1] print field''' if message != "": handler = data_handler() handler_data = str(handler.add_in_field(message, field)) #print handler_data api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.infield.update(data=handler_data) #print products return '%s' % products else: return render_template("dashboard.html") else: render_template("dashboard.html") except: render_template("dashboard.html") #data_object = DAO.DataDAO() #data_object.save_message(processed_text) else: return redirect(url_for('login'))
def all_unbxd_suggestion(): if "mail" in session: try: if request.method == 'POST': message = request.form['command'] print message if message != "": handler = data_handler() handler_data = str(handler.all_unbxd_suggestion(message)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.unbxdsuggestion.all(data=handler_data) response_text_json = json.loads(products) print response_text_json #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['keywordSuggestions']) is list): response_text = '' fld_name = '' for val in response_text_json['keywordSuggestions']: #print val field_name = (val['fields']) for values in field_name: fld_name = fld_name + '>' + str(values) #print type(field_name) flds = str(val['name']) response_text = response_text + (flds + "--->" + fld_name + " ") fld_name = '' #print response_text return '%s' % response_text else: #print response_text return '%s' % response_text_json['errors'][0]['message'] else: return render_template("dashboard.html") else: render_template("dashboard.html") except Exception as e: print e return '%s' % e #data_object = DAO.DataDAO() #data_object.save_message(processed_text) else: return redirect(url_for("login"))
def get_all_infield_data(): if "mail" in session: try: if request.method == 'POST': message = request.form['command'] #print message if message != "": handler = data_handler() handler_data = str(handler.get_all_infield(message)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.infield.all(data=handler_data) response_text_json = json.loads(products) #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['inFields']) is list): response_text = '' if (len(response_text_json['inFields']) > 0): print response_text_json for val in response_text_json['inFields']: #print val fields = str(val) response_text = response_text + (fields + " ") print response_text return render_template("box/table.html", response_text=response_text) else: response_text = "infield_list_is_empty *_*" return render_template("box/error.html", response_text=response_text) else: return render_template( "box/error.html", response_text=response_text_json['errors'][0] ['message']) else: return render_template("unbxd_sugestion.html") else: render_template("unbxd_sugestion.html") except: render_template("login.html") #data_object = DAO.DataDAO() #data_object.save_message(processed_text) else: return redirect(url_for("login"))
def display_popular(): if "mail" in session: # z=str(request.form['command']) company = str(request.args.get('command')) metric = str(request.args.get('metric')) print "company id=>" + z handler = data_handler() if metric == "Popular Product": handler_data = str(handler.all_popular_product(company)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.unbxdsuggestion.all(data=handler_data) response_text_json = json.loads(products) print response_text_json #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['keywordSuggestions']) is list): response_text = '' fld_name = '' outerlist = [] innerlist = [] for val in response_text_json['keywordSuggestions']: #print val field_name = (val['fields']) #print field_name for values in field_name: #print values fld_name = fld_name + str(values) + ',' #print type(field_name) flds = str(val['name']) innerlist.append(flds) innerlist.append(fld_name[0:-1]) outerlist.append(innerlist) innerlist = [] fld_name = '' #print response_text #if request.method=='GET': print outerlist return render_template("box/table.html", response=outerlist) else: redirect(url_for('login'))
def get_popular_product(): if "mail" in session: try: if request.method == 'POST': message = request.form['command'] print message if message != "": handler = data_handler() handler_data = str(handler.all_popular_product(message)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = str(api.popularproduct.all(data=handler_data)) #print products response_text_json = json.loads(products) #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['popularProductFields']) is list): response_text = '' for val in response_text_json['popularProductFields']: field_name = str(val['fieldName']) condition = str(val['required']) response_text = response_text + ( field_name + "--->" + condition + " ") #print response_text #print response_text return '%s' % response_text else: return '%s' % response_text_json['errors'][0]['message'] else: return render_template("dashboard.html") else: return render_template("dashboard.html") except: return render_template("dashboard.html") else: return redirect(url_for('login'))
import numpy as np from scipy.io import loadmat import os from data_handler import * PATH = "C:\OneDrive - Cumberland Valley School District\EEG ScienceFair\database\depression\Matlab Files" for filename in os.listdir(PATH): dl = data_handler(f"{PATH}/{filename}") dl.plot_channel_locations() break
import numpy as np from scipy.io import loadmat import matplotlib.pyplot as plt from data_handler import * from fast_fourier_transform import * from channel_band_amps import channel_band_amps, channel_names, qEEG import os PATH = "C:\OneDrive - Cumberland Valley School District\EEG ScienceFair\database\depression\Matlab Files" band_amps = [] for filename in os.listdir(PATH): file_path = f"{PATH}/{filename}" dl = data_handler(file_path) # Add inheritance between data_handler & channel_bands_amp cba = channel_band_amps(file_path) for channel_data, channel_name in zip(dl.get_EEG()[:64], dl.get_channel_names()[:64]): fft = fast_fourier_transform(channel_data[:15000]) channel_bands = fft.FFT() cba.add_band_amp(channel_bands, channel_name) band_amps = cba.get_bands_amp() QEEG = qEEG(band_amps, file_path) QEEG.graph_XY() break
def add_suggestion_data(): if "mail" in session: try: if request.method == 'POST': print "add suggestion" data_dict = request.form.to_dict() keylist = data_dict.keys() print keylist message = str(data_dict["command"]) data = str(data_dict["data"]) print message, data data = str(data[1:]) if message != "": handler = data_handler() handler_data = str( handler.add_unbxd_suggestion(message, data)) print handler_data api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.unbxdsuggestion.update(data=handler_data) res_popular = response_handler() final_message = str(res_popular.addSuggestion(products)) #return '%s' % final_message #print products return '%s' % final_message else: return render_template("dashboard.html") ''' else: return render_template("dashboard.html") except Exception as e: print e return '%s' % "error" else: return redirect(url_for("login")) #data_object = DAO.DataDAO() #data_object.save_message(processed_text) #return render_template("dashboard.html") #------------------------------------------------------------> #--------------------------delete unbxd suggestion ----------> @app.route('/delete_unbxd_suggestion') def delete_unbxd_suggestion(): if "mail" in session: if request.method=='GET': return render_template("delete_unbxd_suggestion.html") else: return redirect(url_for("login")) @app.route('/delete_suggestion_data', methods=['POST','get']) def delete_suggestion_data(): #print("1") if "mail" in session: try: if request.method=='POST': print ("2") data_dict=request.form.to_dict() print data_dict message=str(request.form['command']) print messagedele field=str(request.form['data']) ''' field = field.split('--->') field = field[0] ''' print message,field if message!="": handler=data_handler() handler_data=str(handler.delete_unbxd_suggestion(message,field)) #print handler_data #api=unbxd.api.PostmanApi(host="feed.unbxdapi.com") #products=api.unbxdsuggestion.delete(data=handler_data) #res_popular=response_handler() #final_message=str(res_popular.delSuggestion(products)) return '%s' % "final_message" #print products else: return render_template("dashboard.html") else: return render_template("dashboard.html") except: return render_template("dashboard.html") else: return redirect(url_for("login")) #data_object = DAO.DataDAO() #data_object.save_message(processed_text) #return render_template("dashboard.html") #------------------------------------------------------------> #--------------------------add popular product --------------> @app.route('/add_popular_product') def add_popular_product(): if "mail" in session: if request.method=='GET': return render_template("add_popular_product.html") else: return redirect(url_for("login")) @app.route('/add_popular', methods=['POST','get']) def add_popular(): if "mail" in session: try: if request.method=='POST': #print "1" data_dict=request.form.to_dict() #print data_dict keylist = data_dict.keys() message=str(data_dict["command"]) field=str(data_dict['fields']) condition=str(request.form['condition']) #print field,message,condition ''' values = [] for val in keylist: if (val[0:6] == "alltxt"): values.append(int(val[6:])) values = sorted(values) #print values string = "" for param in values: #print param #print str(mydict["mytext"+str(param)]) string = string + str( data_dict["mytext" + str(param)]) + "_" field = string[:-2] input_text_list = [] for param in values: input_text_list.append( str(data_dict["alltxt" + str(param)])) string = "" for items in input_text_list: if items != "": string = string + str(items) + "_" field = string[:-1] print field #print field,message,condition''' if message != "": handler = data_handler() handler_data = str( handler.add_popular_product(message, field, condition)) #print handler_data handler_true_data = str( handler.all_popular_product(message)) #print handler_true_data ''' print handler_true_data multiple_true_check=unbxd.api.PostmanApi(host="feed.unbxdapi.com") resp=str(multiple_true_check.popularproduct.all(data=handler_true_data)) print resp res_handler=response_handler() times_true=res_handler.true_check(resp) print type(times_true)''' if (condition == 'false'): api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.popularproduct.update(data=handler_data) #print products res_popular = response_handler() final_message = str(res_popular.addPopular(products)) return '%s' % final_message else: multiple_true_check = unbxd.api.PostmanApi( host="feed.unbxdapi.com") resp = str( multiple_true_check.popularproduct.all( data=handler_true_data)) #print "resp" #print resp res_handler = response_handler() times_true = res_handler.true_check(resp) #print times_true if (times_true <= 0): api = unbxd.api.PostmanApi( host="feed.unbxdapi.com") products = api.popularproduct.update( data=handler_data) #print products res_popular = response_handler() final_message = str( res_popular.addPopular(products)) return '%s' % final_message else: final_message = "true already present->change the condition" return '%s' % final_message else: return render_template("dashboard.html") else: return render_template("dashboard.html") except: return render_template("dashboard.html") else: return redirect(url_for('login'))
def display_suggestion(): if "mail" in session: # z=str(request.form['command']) company = str(request.args.get('command')) metric = str(request.args.get('metric')) #print "company id=>"+z handler = data_handler() if metric == "Suggestion": handler_data = str(handler.all_popular_product(company)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.unbxdsuggestion.all(data=handler_data) response_text_json = json.loads(products) print response_text_json #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['keywordSuggestions']) is list): response_text = '' fld_name = '' outerlist = [] innerlist = [] for val in response_text_json['keywordSuggestions']: #print val field_name = (val['fields']) #print field_name for values in field_name: #print values fld_name = fld_name + str(values) + ',' #print type(field_name) flds = str(val['name']) innerlist.append(flds) innerlist.append(fld_name[0:-1]) outerlist.append(innerlist) innerlist = [] fld_name = '' #print response_text #if request.method=='GET': print outerlist return render_template("box/table.html", response=outerlist, response_text=session) elif metric == "In Field": #try: if company != "": handler = data_handler() handler_data = str(handler.get_all_infield(company)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = api.infield.all(data=handler_data) response_text_json = json.loads(products) #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['inFields']) is list): response_text = [] if (len(response_text_json['inFields']) > 0): print response_text_json for val in response_text_json['inFields']: #print val fields = str(val) response_text.append(fields) print response_text return render_template("box/infield.html", response_text=response_text) else: response_text = ["infield_list_is_empty *_*"] return render_template("box/error.html", response_text=response_text) else: return render_template( "box/error.html", response_text=response_text_json['errors'][0] ['message']) else: return render_template("unbxd_suggestion.html") #except: # render_template("unbxd_suggestion.html")''' elif metric == "Popular Product": if company != "": handler = data_handler() handler_data = str(handler.all_popular_product(company)) api = unbxd.api.PostmanApi(host="feed.unbxdapi.com") products = str(api.popularproduct.all(data=handler_data)) #print products response_text_json = json.loads(products) #print str(asd['popularProductFields'][0]) #print(len(response_text_json['popularProductFields'])) if (type(response_text_json['popularProductFields']) is list): outer = [] inner = [] for val in response_text_json['popularProductFields']: field_name = str(val['fieldName']) condition = str(val['required']) #response_text=response_text+(field_name+"--->"+condition+" ") #print response_text inner.append(field_name) inner.append(condition) outer.append(inner) inner = [] #print response_text return render_template("box/popular.html", response=outer) else: return render_template( "box/error.html", response_text=response_text_json['errors'][0] ['message']) else: return render_template("box/error.html", response_text="Enter the required Metric") else: redirect(url_for('login'))