Beispiel #1
0
 def getResult(self):
     if self.listTest.curselection() != ():
         index = self.listTest.curselection()[0]
         testname = str(self.listTest.get(index))
         testType = [i[3] for i in test_list if i[0] == testname]
         testType = str(testType[0])
         t1 = Toplevel()
         if testType == 'S':
             #> this is horrible...
             duedate = self.turnDueDateToObject(testname)
             print(duedate)
             fdbck = Feedback.Show_Results(t1, login.username, testname,
                                           testType, duedate)
         elif testType == 'F':
             fdbck = Feedback.Show_Results(t1, login.username, testname,
                                           testType)
         else:
             messagebox.showwarning(
                 "Error",
                 "Is your testtype a string other than 'F' or 'S'?")
Beispiel #2
0
 def getStudentResult(self):
     # retrieve their results
     if self.listtests.curselection() != ():
         index = self.listtests.curselection()[0]
         testname = str(self.listtests.get(index))
         #username = userno[studentName]
         #print(testname,username)
         #t1 = Toplevel()
         fdbck = Feedback.Show_Results(Toplevel(), studentNo, testname,
                                       testType, 0, True)
     else:
         messagebox.showerror("Error", "Select a test!")
Beispiel #3
0
    def wishMe(self):
        obj1 = Feedback.Speaker()
        hour = int(datetime.datetime.now().hour)
        if hour >= 0 and hour < 12:
            obj1.speak("Good Morning!")

        elif hour >= 12 and hour < 18:
            obj1.speak("Good Afternoon!")

        else:
            obj1.speak("Good Evening!")

        obj1.speak("I am David, Please tell me how may I help you")
Beispiel #4
0
def createFeedback():
    updateFeedbackForm = CreateFeedback(request.form)
    if request.method == 'POST' and updateFeedbackForm.validate():
        feedbackDict = {}
        db = shelve.open('feedback.db', 'c')

        try:
            feedbackDict = db['Feedback']
        except:
            print('Error in retrieving feedback from Feedback.db.')

        feedback = Feedback.Feedback(updateFeedbackForm.name.data, updateFeedbackForm.number.data, updateFeedbackForm.feedbackZ.data)
        feedbackDict[feedback.get_feedbackID()] = feedback
        db['Feedback'] = feedbackDict
        db.close()

        return redirect(url_for('home'))
    return render_template('contactUs.html', form=updateFeedbackForm, status='admin')
     time.strptime(dt, '%Y-%m-%d %H:%M:%S')
     s = time.mktime(time.strptime(dt, '%Y-%m-%d %H:%M:%S'))
     return int(s)
     
def timestamp_datetime(value):
    format = '%Y-%m-%d %H:%M:%S'
    value = time.localtime(value)
    dt = time.strftime(format, value)
    return dt
     
def Getweek(num):
    string = ['日','一','二','三','四','五','六']
    return string[num]


fb = Feedback()
query = '{query}'
# t:今天新番
# r:最近更新
# 3:三次元
# wn:查询星期n

appkey='03fc8eb101b091fb';

qtype = 2;
qmode = 'r'
qweek = None
opt = re.findall(r'^(\d)',query)
if opt != []:
    qtype = int(opt[0])
    if qtype not in [2,3]:
# -*- coding: utf-8 -*-
"""
Created on Mon May 26 23:42:03 2014

@author: Vespa
"""

import os

from Feedback import *

fb = Feedback()

Desktop_Path = '%s/Desktop/'%(os.path.expanduser('~'))
list_dirs = os.listdir(Desktop_Path)
for line in list_dirs:
    filepath = os.path.join(Desktop_Path,line)
    if not os.path.isdir(filepath):
        if line.endswith('xml'):
            xmlid = line.split('.')[0]
            fb.add_item(xmlid+'.xml',subtitle='转化'+xmlid+'.xml',arg=xmlid)

print fb
    params["appkey"] = appkey
    data = ""
    paras = params.keys()
    paras.sort()
    for para in paras:
        if data != "":
            data += "&"
        data += para + "=" + params[para]
    if AppSecret == None:
        return data
    m = hashlib.md5()
    m.update(data + AppSecret)
    return data + "&sign=" + m.hexdigest()


fb = Feedback()
av = "{query}"
appkey = "03fc8eb101b091fb"
regex = re.compile("http:/*[^/]+/video/av(\\d+)(/|/index.html|/index_(\\d+).html)?(\\?|#|$)")
regex_match = regex.match(av)
if regex_match:
    aid = regex_match.group(1)
    pid = regex_match.group(3) or "1"
    vedio = GetVedioInfo(aid, appkey, AppSecret=None, page=pid)
    try:
        if pid == "1":
            fb.add_item(
                "转化" + vedio.title,
                subtitle="弹幕cid:%d" % (vedio.cid),
                arg=str(vedio.cid) + "------" + vedio.title + "------" + pid,
            )
    params['appkey'] = appkey
    data = ""
    paras = params.keys()
    paras.sort()
    for para in paras:
        if data != "":
            data += "&"
        data += para + "=" + params[para]
    if AppSecret == None:
        return data
    m = hashlib.md5()
    m.update(data + AppSecret)
    return data + '&sign=' + m.hexdigest()


fb = Feedback()
av = '{query}'
appkey = "03fc8eb101b091fb"
regex = re.compile(
    'http:/*[^/]+/video/av(\\d+)(/|/index.html|/index_(\\d+).html)?(\\?|#|$)')
regex_match = regex.match(av)
if regex_match:
    aid = regex_match.group(1)
    pid = regex_match.group(3) or '1'
    vedio = GetVedioInfo(aid, appkey, AppSecret=None, page=pid)
    try:
        if pid == '1':
            fb.add_item('转化' + vedio.title,
                        subtitle="弹幕cid:%d" % (vedio.cid),
                        arg=str(vedio.cid) + '------' + vedio.title +
                        '------' + pid)
 def test_execute(self, mocked_params):
     fb = Feedback()
     fb.execute(input_message="fake message", params=mocked_params)
     assert not fb._params
Beispiel #10
0
    for para in paras:
        if data != "":
            data += "&";
        data += para + "=" + str(params[para]);
    if AppSecret == None:
        return data
    m = hashlib.md5()
    m.update((data+AppSecret).encode('utf-8'))
    return data+'&sign='+m.hexdigest()

def ChangeFuck(params):
    data = "";
    paras = params;
    for para in paras:
        if data != "":
            data += "&";
        data += para + "=" + str(params[para]);
    return data

fb = Feedback()
url = '{query}'
# url = 'http://www.bilibili.com/video/av3033822/'
av = GetRE(url,r"\d+")[0]
video = GetVideoInfo(av,appkey=APPKEY,AppSecret=APPSEC)
downloadUrl = GetBilibiliUrl(url)
# print video.title
# print downloadUrl


fb.add_item('获取'+url+'下载地址',subtitle=video.title,arg=downloadUrl)
print fb
Beispiel #11
0
        video.cover = video_idx['pic']
        video.guankan = video_idx['play']
        video.danmu = video_idx['video_review']
        video.shoucang = video_idx['favorites']
        video.commentNumber = video_idx['review']
        video.date = video_idx['pubdate']
        video.tag = video_idx['tag'].split(',')
        videolist.append(video)
    return videolist


query = '{query}'
appkey = '70472776da900153'
secretkey = 'f7d9146f9363f3407d31098918493336'
videoList = biliVideoSearch(appkey, secretkey, query, pagesize=30)
fb = Feedback()

try:
    for video in videoList:
        fb.add_item(video.title,
                    subtitle="%s : http://www.bilibili.com/video/%s(%s)" %
                    (video.typename, video.aid,
                     datetime.datetime.utcfromtimestamp(
                         video.date).strftime(r"%Y/%m/%d")),
                    arg=video.aid)

except SyntaxError as e:
    if ('EOF', 'EOL' in e.msg):
        fb.add_item('...')
    else:
        fb.add_item('SyntaxError', e.msg)
    return int(s)


def timestamp_datetime(value):
    format = '%Y-%m-%d %H:%M:%S'
    value = time.localtime(value)
    dt = time.strftime(format, value)
    return dt


def Getweek(num):
    string = ['日', '一', '二', '三', '四', '五', '六']
    return string[num]


fb = Feedback()
query = '{query}'
# t:今天新番
# r:最近更新
# 3:三次元
# wn:查询星期n

appkey = '03fc8eb101b091fb'

qtype = 2
qmode = 'r'
qweek = None
opt = re.findall(r'^(\d)', query)
if opt != []:
    qtype = int(opt[0])
    if qtype not in [2, 3]:
Beispiel #13
0
class Test:
    client = wolframalpha.Client('634LX2-LYYPLU7W44')

    if __name__ == "__main__":
        obj = SpeechAnalysis.SpeechInput()
        obj1 = Feedback.Speaker()
        objf = SystemAutomation.AutomateBrowser()
        obj1.wishMe()

        while True:
            query = obj.takecommand().lower()
            if query == "None":
                continue
            # print(query)
            # obj1.speak(query)
            if "goodbye" in query:
                obj1.speak("Have a nice day, Sir!")
                break

            elif "wikipedia" in query:
                obj1.speak('Searching Wikipedia...')
                query = query.replace("wikipedia", "")
                results = wikipedia.summary(query, sentences=2)
                obj1.speak("According to Wikipedia")
                print(results)
                obj1.speak(results)

            elif "open file browser" in query:
                filePath = "C:\\Users\\HemantMalik"
                os.startfile(filePath)

            elif "open torrent" in query:
                filepath = "C:\\Program Files\\qBittorrent\\qbittorrent.exe"
                os.startfile(filepath)

            elif 'send email' in query:
                try:
                    obj1.speak("What should I say?")
                    content = obj.takecommand()
                    to = query.split(" ")
                    to = to[-1]
                    objf = SystemAutomation.AutomateBrowser(to, content)
                    objf.sendEmail()
                    obj1.speak("Email has been sent!")
                except Exception as e:
                    print(e)
                    obj1.speak("Sorry Sir, I am not able to send this email")

            elif "open google" in query or "open Chrome" in query:
                webbrowser.open("google.com")

            elif "open youtube" in query:
                webbrowser.open("youtube.com")

            elif "open website" in query or "open a website" in query:
                obj1.speak("Which website would you like to open?")
                website = obj.takecommand()
                if website != "None":
                    webbrowser.open(website + ".com")

                else:
                    obj1.speak(
                        "Website unrecognizable, Please enter a valid website."
                    )

            elif "login to my facebook" in query:
                obj1.speak("Please, tell me your secret passkey.")
                passkey = obj.takecommand().lower()
                if "1234" in passkey:
                    try:
                        objf.facebookLogin()
                    except:
                        obj1.speak("Login Failed, Please try again.")
                else:
                    obj1.speak("Invalid Passkey entered please try again!")

            elif "send whatsapp message" in query:
                obj1.speak("To whom do you want to send message?")
                to = obj.takecommand()
                # print(to)
                if to != "None":
                    obj1.speak("What should i say?")
                    message = obj.takecommand()
                    # print(message)
                    if message != "None":
                        objf = SystemAutomation.AutomateBrowser(to, message)
                        objf.whatsappMess()
                    else:
                        obj1.speak(
                            "Sorry Sir!, I am unable to send an empty message."
                        )
                else:
                    obj1.speak("Unable to identify receiver.")

            elif "who are you" in query or "what is your name" in query:
                obj1.speak("I am David, Your Desktop voice assistant")

            elif "watch movie" in query or "play movie" in query or "open movie" in query or "start movie" in query:
                filepath = r"D:\\The Shawshank Redemption (1994) 720p BrRip x264 [Dual Audio] [Hindi-English].mkv"
                os.startfile(filepath)

            elif 'play music' in query or "open music" in query or "listen music" in query or "start music" in query:
                music_dir = r'D:\Hemant\Enrique Iglesias Discography (iTunes-Rip) [theLEAK]\Studio Albums\7 (UK Version)'
                songs = os.listdir(music_dir)
                # print(songs, sep="\n")
                song = random.randrange(16)
                os.startfile(os.path.join(music_dir, songs[song]))

            elif "google search" in query or "search google" in query or "search on google" in query:
                obj1.speak("What do you want me to search.")
                searchcontent = obj.takecommand()
                objf = SystemAutomation.AutomateBrowser("", searchcontent)
                try:
                    objf.googlesearch()
                except:
                    obj1.speak("Unable to proceed with google search. Sir!")

            elif "youtube search" in query or "search youtube" in query or "search on youtube" in query:
                obj1.speak("What do you want me to search.")
                searchcontent = obj.takecommand()
                objf = SystemAutomation.AutomateBrowser("", searchcontent)
                try:
                    objf.youtubesearch()
                except:
                    obj1.speak("Unable to proceed with Youtube search, Sir!")

            else:
                try:
                    if query != "none":
                        # print(query)
                        res = client.query(query)
                        output = next(res.results).text
                        print(output)
                        obj1.speak(output)
                except:
                    obj1.speak(
                        "Sorry, I am unable to answer this question, Sir! Do You want me to search it on google"
                    )
                    dosearch = obj.takecommand()
                    if "yes" in dosearch:
                        objf = SystemAutomation.AutomateBrowser("", query)
                        objf.googlesearch()
def main():
    st.set_page_config(page_title='COVIDvisor')
    # st.title('COVIDvisor')
    sidebarTitle = st.sidebar.title('COVIDvisor')

    menu = ['Home', 'Test', 'View Data', 'About']
    page = st.sidebar.selectbox('Main Menu',
                                ('Home', 'Test', 'View Data', 'About'))
    if page == "Test":
        st.title('Feeling sick?')
        rand_forest, features = Model.train_data('Covid Dataset.csv')

        st.write(""" 
            ## Input your symptoms and get a preliminary diagnosis.
        """)

        dataset_name = st.sidebar.selectbox('Select Illness to test for',
                                            ('COVID-19', 'Common Cold', 'Flu'))

        st.write(f"### Currently testing for {dataset_name} ")

        breathingAnswer = st.selectbox('Do you have any breathing problems?', (
            '-----',
            'Yes',
            'No',
        ))
        feverAnswer = st.selectbox(
            'Do you have a Fever (body temperature above 38˚C) ?', (
                '-----',
                'Yes',
                'No',
            ))
        dryCoughAnswer = st.selectbox('Do you a dry cough?', (
            '-----',
            'Yes',
            'No',
        ))
        soreThroatAnswer = st.selectbox('Do you a sore throat?', (
            '-----',
            'Yes',
            'No',
        ))
        runningNoseAnswer = st.selectbox('Do you a running nose?', (
            '-----',
            'Yes',
            'No',
        ))
        asthmaAnswer = st.selectbox('Do you have asthma?', (
            '-----',
            'Yes',
            'No',
        ))
        chronicLungDiseaseAnswer = st.selectbox(
            'Do you have chronic Lung Disease?', (
                '-----',
                'Yes',
                'No',
            ))
        headacheAnswer = st.selectbox('Have you experienced headache?', (
            '-----',
            'Yes',
            'No',
        ))
        heartDiseaseAnswer = st.selectbox('Do you have heart Disease?', (
            '-----',
            'Yes',
            'No',
        ))
        diabetesAnswer = st.selectbox('Do you have diabetes?', (
            '-----',
            'Yes',
            'No',
        ))
        hyperTensionAnswer = st.selectbox(
            'Have your experienced any hyper Tension?', (
                '-----',
                'Yes',
                'No',
            ))
        fatigueAnswer = st.selectbox('Are you fatigued last couple days?', (
            '-----',
            'Yes',
            'No',
        ))
        gastrointestinalAnswer = st.selectbox(
            'Do you have Gastrointestinal Disease?', (
                '-----',
                'Yes',
                'No',
            ))
        abroadTravelAnswer = st.selectbox('Have you travelled abroad?', (
            '-----',
            'Yes',
            'No',
        ))
        contactWithCOVIDPatientAnswer = st.selectbox(
            'Were you in close contact with another COVID-19 postive patient last couple weeks?',
            (
                '-----',
                'Yes',
                'No',
            ))
        attendedLargeGatheringAnswer = st.selectbox(
            'Did you attend any large gathering last couple weeks?', (
                '-----',
                'Yes',
                'No',
            ))
        visitedPublicExposedPlacesAnswer = st.selectbox(
            'Have you visited any public exposed places?', (
                '-----',
                'Yes',
                'No',
            ))
        familyWorkingInPublicExposedPlacesAnswer = st.selectbox(
            'Do you have any family members that are currently working in publicly exposed places?',
            (
                '-----',
                'Yes',
                'No',
            ))

        user_answers = [
            breathingAnswer, feverAnswer, dryCoughAnswer, soreThroatAnswer,
            runningNoseAnswer, asthmaAnswer, chronicLungDiseaseAnswer,
            headacheAnswer, heartDiseaseAnswer, diabetesAnswer,
            hyperTensionAnswer, fatigueAnswer, gastrointestinalAnswer,
            abroadTravelAnswer, contactWithCOVIDPatientAnswer,
            attendedLargeGatheringAnswer, visitedPublicExposedPlacesAnswer,
            familyWorkingInPublicExposedPlacesAnswer
        ]

        if st.button("Get Checked"):

            page = "Home"
            st.success(
                f'Results submitted. Go to View Data page for detailed report')
            pos, neg = Model.test(rand_forest,
                                  Model.answer_conversion(user_answers))
            suggestedFeedback = Feedback.feedback(pos)
            st.write(
                f'You have {int(pos)} % of catching the Novel Coronavirus (COVID-19)'
            )
            st.write(f'Feedback: {suggestedFeedback}')
            but = st.button("View Detail Results")
            # if but:
            #     page = 'View Data'
            # if st.button("Check your detailed report"):

    elif page == 'Home':
        st.title('COVIDvisor')

        st.write(""" 
            ## dedicated to providing an accurate pre-screening and initial diagnosis service for users with common illnesses in order to minimise unnecessary social contacts and the pressure of public hospitals.
            """)
        image = Image.open('doctor_image.jpg')
        st.image(image, use_column_width=True)
        st.write(
            'Our solution is a machine learning (web) application that provides users with an accurate preliminary diagnosis given their input of symptoms currently experienced. The algorithm will suggest 3 top illnesses with the highest likelihood and for each illness, also giving the proper treatment methods and guidelines. '
        )

    elif page == 'View Data':
        st.title('Your Result')
        col1, col2 = st.beta_columns(2)
        with col1:
            st.header('What should I do?')
            st.write('''
                Avoid all social contact immediately to prevent spreading the virus to others.
                If your symptoms are severe and you are feeling unwell, please visit AE in hospital. Otherwise,
                test for COVID in one of the following locations. In the meantime, stay hydrated and get enough rest,
                and be sure to notify your family and friends.
            ''')

            st.subheader('Key symptoms you had related to COVID-19')
            st.write('**Fever**')
            st.write('''
                Fever is the most common symptom of COVID-19. 
                Seek medical advice and enforce social distancing if the conditions continue.
            ''')
            st.write('**Dry Cough**')
            st.write('''
                Studies have found that at least 60\%\of people with COVID-19 have a dry cough. Stay vigilant if you are having
                these symptoms.
            ''')
            st.write('**Contact with COVID-19 Patient**')
            st.write('''
                COVID-19 can spread from an infected person's mouth or nose in small liquid particles when
                they cough, sneeze, speak, sing or breathe heavily.
            ''')

        with col2:
            st.header('Your risk level is **92%**:')
            riskLevel = st.select_slider('',
                                         options=['Low', 'Medium', 'High'],
                                         value='High')

            st.write('Your risk level of getting COVID-19 is **', riskLevel,
                     '**')

            st.button('Consult a doctor')
            st.write(
                '**CONDUCT A THOROUGH COVID-19 TEST AT THE NEAREST TEST CENTER**'
            )

            # insert map
            data = [[22.336241357823056, 114.16659858285237]]
            centerDF = pd.DataFrame(data, columns=['lat', 'lon'])
            st.map(centerDF)

            st.write(
                'Closest Test Centre: **Pak Tin Community Hall in Sham Shui Po**'
            )

            st.write(
                '**Address**: Pak Tin Estate, Pak Tin Street, Shek Kip Mei, Sham Shui Po, Kowloon'
            )
            st.write(
                '**Contractor**: Hong Kong Molecular Pathology Diagnostic Centre Limited'
            )
            st.write('**Hotline**: 3611 1301 / 3611 1302')
            st.write('**Email**: [email protected]')
    else:
        st.title('Further development')
        st.write(
            'Our application \'s position is to detect common illnesses as a starting point. However, with our application proven to be an effective tool for pre-screening / preliminary diagnosis, we can partner with the Hong Kong Government\'s  eHealth (醫健通) programme to allow users to import / link their medical history, further increasing the accuracy of the diagnosis results'
        )
Beispiel #15
0
    m = hashlib.md5()
    m.update((data + AppSecret).encode('utf-8'))
    return data + '&sign=' + m.hexdigest()


def ChangeFuck(params):
    data = ""
    paras = params
    for para in paras:
        if data != "":
            data += "&"
        data += para + "=" + str(params[para])
    return data


fb = Feedback()
url = '{query}'
# url = 'http://www.bilibili.com/video/av2968792/'
av = GetRE(url, r"\d+")[0]
video = GetVideoInfo(av, appkey=APPKEY, AppSecret=APPSEC)
downloadUrls = GetBilibiliUrl(url)
# print video.title
# for downloadUrl in downloadUrls:
#     print downloadUrl

for id, downloadUrl in enumerate(downloadUrls):
    fb.add_item('获取' + url + '下载地址',
                subtitle="%s(%d P)" % (video.title, id + 1),
                arg=downloadUrl)

print fb
        video.description = video_idx['description']
        video.arcrank = video_idx['arcrank']
        video.cover = video_idx['pic']
        video.guankan = video_idx['play']
        video.danmu = video_idx['video_review']
        video.shoucang = video_idx['favorites']
        video.commentNumber = video_idx['review']
        video.date = video_idx['pubdate']
        video.tag = video_idx['tag'].split(',')
        videolist.append(video)
    return videolist

query = '{query}'
appkey = '70472776da900153'
secretkey = 'f7d9146f9363f3407d31098918493336'
videoList = biliVideoSearch(appkey,secretkey,query, pagesize = 30)
fb = Feedback()

try:
    for video in videoList:
        fb.add_item(video.title,subtitle="%s : http://www.bilibili.com/video/%s(%s)"%(video.typename,video.aid,datetime.datetime.utcfromtimestamp(video.date).strftime(r"%Y/%m/%d")),arg=video.aid)

except SyntaxError as e:
    if ('EOF', 'EOL' in e.msg):
        fb.add_item('...')
    else:
        fb.add_item('SyntaxError', e.msg)
except Exception as e:
        fb.add_item(e.__class__.__name__,subtitle=e.message)
print fb