def wrap(*args,**kwargs): if 'user' in flask.session: flask.flash("You need to log out first") dbh = DatabaseHelper.getInstance() nm = NotificationManager.getInstance(flask.session['sessionID']) return flask.render_template('menu.html', message=nm.getUserNotifications(), days=json.dumps(dbh.getTakenDays(flask.session['sessionID']))) else: return f(*args,**kwargs)
def wrap(*args,**kwargs): nm = NotificationManager.getInstance(flask.session['sessionID']) dbh = DatabaseHelper.getInstance() acc,filename,wpm,var,mFreq,brTime,avgAmp = dbh.return_audiorecordings(flask.session['sessionID']) if len(filename) == 0: if not nm.newStartGiven: nm.addNotification("Hi " + flask.session['user'] + ', and welcome to PAPA! It seems to be your first time using this app. Please click the help button to get started.', "help", "PAPA Team") nm.newStartGiven = True return f(*args,**kwargs)
def getOrdering(self, userID): listFilled = [] dbh = DatabaseHelper.getInstance() prefs = dbh.return_text_pref(userID) for i in prefs: if i != "NULL" and i != '': listFilled.append(i) for i in os.listdir('files/daily-articles/'): if i not in listFilled and i != 'ArticleSites.txt' and i != ".DS_Store": listFilled.append(i) return listFilled
def insertAnalyzeData(self): try: peakspermin = (self.peaks / self.duration) * 60 self.logger.debug("PeaksPerMin = {}") troughspermin = (self.troughs / self.duration) * 60 self.logger.debug("troughspermin") blinkspermin = (self.blinks / self.duration) * 60 self.logger.debug("blinkspermin") self.dbh = DatabaseHelper.getInstance() self.dbh.insert_videorecordings(self.userId, self.blinks, self.peaks, self.troughs, blinkspermin, peakspermin, troughspermin, self.duration, self.filename, self.case) self.logger.info("Data has been inserted into the Database") self.resetValues() return True except: self.logger.error("Insert Analyze Failed") return False
def beginAnalysisThread(self, user, userId, dbh, filename, case): try: self.case = case self.filename = filename + ".avi" self.dbh = DatabaseHelper.getInstance() self.username = user self.userId = userId self.VIDEOPATH = str(os.getcwd() + "\\recordings_video\\" + self.username + "\\" + self.filename) self.out = cv2.VideoWriter(self.VIDEOPATH, self.fourcc, 20.0, (320, 240)) self.logger.info("Video Created at:{0}".format(self.VIDEOPATH)) self.logger.info( "Analysis Thread has Begun(user:{0}, userId:{1},filename:{2})". format(self.username, self.userId, self.filename)) self.Thread = threading.Thread(target=self.analyzeVideoRecording, args=(case, filename, user, userId)) self.Thread.start() return True except Exception as e: self.logger.error("Tried to Begin Thread:{0}".format(e)) return False
def wrap(*args,**kwargs): nm = NotificationManager.getInstance(flask.session['sessionID']) dbh = DatabaseHelper.getInstance() acc,filename,wpm,var,mFreq,brTime,avgAmp = dbh.return_audiorecordings(flask.session['sessionID']) ch_acc,ch_wpm,ch_var,ch_mFreq,ch_breath,ch_avgAmp,ch_blink,ch_jvib = dbh.return_config(flask.session['sessionID']) filename,total_blinks,total_peaks,total_troughs,blinkspermin,peakspermin,troughspermin,video_duration = dbh.return_videoRecordings(flask.session['sessionID']) try: if len(acc) >5: avg_acc = (sum(acc) - acc[-1])/(len(acc) - 1) avg_wpm = (sum(wpm) - wpm[-1])/(len(wpm) - 1) avg_var = (sum(var) - var[-1])/(len(var) - 1) avg_mFreq = (sum(mFreq) - mFreq[-1])/(len(mFreq) - 1) avg_brTime = (sum(brTime) - brTime[-1])/(len(brTime) - 1) avg_avgAmp = (sum(avgAmp) - avgAmp[-1])/(len(avgAmp) - 1) avg_blinkspermin = (sum(blinkspermin) - blinkspermin[-1])/(len(blinkspermin) - 1) avg_peakspermin = (sum(peakspermin) - peakspermin[-1])/(len(peakspermin) - 1) if (((acc[-1]/avg_acc)-100) <= -ch_acc) or (((wpm[-1]/avg_wpm)-100) <= -ch_wpm) or (((var[-1]/avg_var)-100) <= -ch_var) or (((brTime[-1]/avg_brTime)-100) <= ch_breath) or (((avg_avgAmp[-1]/avg_avgAmp)-100) <= -ch_avgAmp) or (((mFreq[-1]/avg_mFreq)-100) <= -ch_mFreq or (((blinkspermin[-1]/avg_blinkspermin)-100) <= -ch_blink) or (((peakspermin[-1]/avg_peakspermin)-100) <= ch_jvib)): nm.addNotification('We have noticed some changes in your results, your doctor has been notified, but you may wish to book an appointment',"deterioration","Analysis Team") nm.sendDoctorNotifications("Hello", "*****@*****.**") return flask.render_template('menu.html', message=nm.getUserNotifications(), days=json.dumps(dbh.getTakenDays(flask.session['sessionID']))) except: return flask.render_template('menu.html', message=nm.getUserNotifications(), days=json.dumps(dbh.getTakenDays(flask.session['sessionID']))) return f(*args,**kwargs)