Example #1
0
def do(speech):

     factory = ChatterBotFactory()

     bot1 = factory.create(ChatterBotType.CLEVERBOT)
     bot1session = bot1.create_session()

     bot2 = factory.create(ChatterBotType.PANDORABOTS, 'b0dafd24ee35a477')
     bot2session = bot2.create_session()

     while(speech!="bye bye"):

        if speech.find("search twitter for")!=-1:
             speech=speech.replace("search twitter for",'')
             search.main(speech)
        elif speech.find("show twitter trend")!=-1:
             trending.main()
        elif speech.find("tell the weather")!=-1:
             weather.main()
        elif speech.find('show my e-mail')!=-1:
             mailtest.main()
        elif speech.find('send email')!=-1:
             mailtest2.main()
        elif speech.find('search bing for')!=-1:
             speech=speech.replace('search bing for','')
             bingsearch.main(speech)
        else:
             s = bot2session.think(speech);
             print 'yam> ' + s
             talks.main(s) 
            

        speech=listen()
        speech=speech.lower()     
def dataCollectionHandler():
    usr_input = input(
        "Would you like to collect track data, weather data, or both? [t/w/b]")
    if usr_input.lower() == 't':
        spotifyCollection.main()
    elif usr_input.lower() == 'w':
        weather.main()
    elif usr_input.lower() == 'b':
        spotifyCollection.main()
        weather.main()
    else:
        print("Invalid input. Please try again.")
        return dataCollectionHandler()
Example #3
0
def start():
    while True:
        date = time.strftime("%Y-%m-%dT%H:%M:%S-04:00")
        # color_start()

        # set_color(COLOR['Red'])
        detector.main()

        # set_color(COLOR['Green'])
        therm.main(number_of_lines, date)

        # set_color(COLOR['Blue'])
        weather.main(number_of_lines, date)

        # color_stop()
        time.sleep(period_btw_save)
Example #4
0
def inquire():
    if request.method == 'POST':
        #从页面通过表单form接收参数
        start = request.form['start']
        end = request.form['end']
        date = request.form['date']
        print(start, end, date)
        print(type(start), type(end), type(date))
        # 调用weather天气模块
        tianqi = weather.main(end, date)
        # 调用爬虫模块
        result = str(pacong.mian(date, start, end))
        print(end, '天气', tianqi, type(tianqi))
        print('车票信息结果的类型:', type(eval(result)))
        print('车票结果:', eval(result))
        dic = {
            'end': end,
            'tianqi': tianqi,
            'result': eval(result),
            'username': username
        }
        print("********", username)
        # 调用render_template函数,它会直接找templates这个文件夹,然后跳转到inquire.html页面(查询页面),传入封装成字典之后的参数
        #查询之后的页面
        return render_template('inquire.html', **dic)
        #return render_template('inquire.html',end1=u'%s'%end,result1=u'%s'%tianqi,result2=u'%s'%result)
    #查询的时候的页面
    return render_template('inquire.html')
def test_1(monkeypatch):

    #input_values = 'York Airport\n'

    #weather.input = input_values
    monkeypatch.setattr('sys.stdin', airport_name)

    assert main() != 'no airport found'
Example #6
0
    def __init__(self):
        self.dailyBibleVerse = dailyVerse.getDailyVerse()
        self.weatherData = weather.main()
        self.tasks = todoist.main()
        """
        try:
            self.calendarEvents = calendar.main()
        except:
            self.calendarEvents = None"""

        self.iconDict = {
            "clear-day": "B",
            "clear-night": "C",
            "rain": "R",
            "snow": "U",
            "sleet": "W",
            "wind": "S",
            "fog": "L",
            "cloudy": "N",
            "partly-cloudy-day": "H",
            "partly-cloudy-night": "I",
            "thunderstorm": "O",
            "hail": "X",
        }

        mainfontname = './fonts/wqy-microhei.ttc'
        global font65
        font65 = ImageFont.truetype(mainfontname, 65)
        global font48
        font48 = ImageFont.truetype(mainfontname, 48)
        global font36
        font36 = ImageFont.truetype(mainfontname, 36)
        global font24
        font24 = ImageFont.truetype(mainfontname, 24)
        global font20
        font20 = ImageFont.truetype(mainfontname, 20)
        global font18
        font18 = ImageFont.truetype(mainfontname, 18)
        global font16
        font16 = ImageFont.truetype(mainfontname, 16)
        global verseTitleFont
        verseTitleFont = ImageFont.truetype('./fonts/Roboto-BoldCondensed.ttf',
                                            20)
        global verseFont
        verseFont = ImageFont.truetype('./fonts/Roboto-Regular.ttf', 18)
        global weather_icons
        weather_icons = ImageFont.truetype('./fonts/meteocons-webfont.ttf', 90)
Example #7
0
def AssistantSkill(cmd):
    try:
        if vision.split(cmd) in web_dict:
            search.search_web(cmd)
            return

        elif cmd in media_toggle[0]:
            vision.speak("opening your music player")
            mediaplayer.music()
            return

        elif cmd in media_toggle[1]:
            vision.speak("opening your video player")
            mediaplayer.video()
            return

        elif 'send email' in cmd or 'sent mail' in cmd:
            mail.mail()
            return

        elif "who are you" in cmd or "define yourself" in cmd:
            speaks = '''Hello, I am Person. Your personal Assistant. I am here to make your life easier. You can 
            command me to perform various tasks such as calculating sums or opening applications etc '''
            vision.speak(speaks)
            return

        elif "who made you" in cmd or "created you" in cmd:
            speaks = "I have been created by Developer."
            vision.speak(speaks)
            return

        elif "calculate" in cmd.lower():
            wolframalph.WolframSkills(cmd)
            return

        elif cmd in frequent[1]:
            date_time.tell_the_date()
            return

        elif cmd in frequent[0]:
            date_time.tell_the_time()
            return

        elif cmd in system_toggle:
            systeminfo.SystemInfo()
            return

        elif 'network speed' in cmd:
            netinfo.Speed()
            return

        elif 'check internet connection' in cmd:
            netinfo.InternetConnection()
            return

        elif 'open' in cmd:
            desktopapps.open_application(cmd)
            return

        elif 'close' in cmd:
            desktopapps.close_application(cmd)
            return

        elif 'news' in cmd:
            news.news(cmd)
            return

        elif "weather" in cmd:
            weather.main(cmd)
            return

        elif cmd in whereAbouts:
            location.location()
            return

        elif "shutdown" in cmd:
            os.system("shutdown /s /t 1")
            return

        elif "restart" in cmd:
            os.system("shutdown /r /t 1")
            return

        else:
            vision.speak("Please check my skill listed in info file...")
            return

    except Exception as e:
        vision.speak(e)
        return
Example #8
0
import urllib2
import sys
import gmail
import gcalendar
import weather
import time
import locale
import notif
from os import system

try:
    locale.setlocale(locale.LC_ALL,'fr_FR')
except:
    locale.setlocale(locale.LC_ALL,'')

system('say Bonjour Monsieur.')
system('say "Nous sommes le %s."' % (time.strftime ("%A %d %B %Y")))
system('say "Il est %s heure %s."' % (time.strftime("%H"),time.strftime("%M")))
system('say "%s"' % weather.main().encode('utf8'))
system('say "%s"' % gmail.main().encode('utf8'))
system('say "%s"' % gcalendar.main().encode('utf8'))
Example #9
0
def run_alexa():
    command = take_command()
    print(command)
    if 'play' in command:
        song = command.replace('play', '')
        talk('playing' + song)
        pywhatkit.playonyt(song)

    elif 'open notepad' in command:

        subprocess.Popen('notepad.exe')

    elif 'close notepad' in command:
        os.system('TASKKILL /F /IM notepad.exe')

    elif 'close chrome' in command:
        os.system('TASKKILL /F /IM chrome.exe')

    elif 'open chrome' in command:
        print('gfjhfj')
        subprocess.call('chrome.exe')

    elif 'open telegram' in command:
        subprocess.Popen('telegram.exe')

    elif 'time' in command:
        time = datetime.datetime.now().strftime('%I:%M %p')
        print(time)
        talk('current time is ' + time)

    elif 'who is' in command:
        person = command.replace('who is', '')
        info = wikipedia.summary(person, 2)
        print(info)
        talk(info)
    elif 'date' in command:
        talk('sorry, i have a headache')

    elif 'are you single' in command:
        talk('i am in a relationship with wifi')

    elif 'weather' in command:

        talk("Where are you now")
        place = command
        wt.main(place)

        temp = wt.current_temperature

        descri = wt.weather_description
        talk("Current Temperature" + str(temp) + "kelvin")
        talk("Current weather is" + descri)

    elif 'what is' in command:
        what = command.replace('what is', '')
        info = wikipedia.summary(what, 2)
        print(info)
        talk(info)
    elif 'joke' in command:
        talk(pyjokes.get_joke())

    elif 'search' in command:

        searched = command.replace('search', '')

        for j in search(searched, tld="com", num=10, stop=10, pause=2):
            print(j)

        talk("Here is the search result")

    else:
        talk('i didnt get that')
Example #10
0
# 给好友发送天气情况
#coding=utf-8
import itchat
import weather

itchat.auto_login(hotReload=True)
friends_list = itchat.get_friends(update=True)
name = itchat.search_friends(name=u'阿樱')
Aying = name[0]["UserName"]

message_list = weather.main('广州')  # 发送天气情况
itchat.send(message_list, Aying)
Example #11
0
def weather_today():
    weather.main()
    return 'Line notifyにより本日の天気が送信されました'
Example #12
0
from datetime import datetime
import weather
import json
from pprint import pprint

# weather.main(datetime(2018, 8, 9))

with open('busdata.json', 'r') as f:
    data = json.load(f)

dates = []

for item in data:
    if item['time'][0:10] not in dates:
        dates.append(item['time'][0:10])

for date in dates:
    useDate = date.split('-')
    useDate = datetime(int(useDate[0]), int(useDate[1]), int(useDate[2]))
    weather.main(useDate)
Example #13
0
def write_msg(user_id, s):
    vk.method('messages.send', {
        'user_id': user_id,
        'attachment': 'photo299887547_456242309',
        'message': s
    })


while True:
    response = vk.method('messages.get', values)
    if response['items']:
        values['last_message_id'] = response['items'][0]['id']
        msg = response['items'][0]['body'].lower()
        weathermsg = {
            "погода", "gjujlf", "погода сегодня", "gjujlf yf ctujlyz",
            "gjujlf ctujlyz", "погода на сегодня"
        }
        weathermsg2 = {
            "погода на завтра", "gjujlf yf pfdnhf", "gjujlf pfdnhf",
            "погода завтра"
        }
        weat.main()
        if msg in weathermsg:
            for item in response['items']:
                write_msg(item[u'user_id'], weat.pogoda1)
        elif msg in weathermsg2:
            for item in response['items']:
                write_msg(item[u'user_id'], weat.pogoda2)
    time.sleep(1)
Example #14
0
def location(message):
    bot.send_message(message.chat.id, weather.main(message.location))
Example #15
0
def do_intent(text, tok):

    sm = hass()
    m = xlMusic()
    services = {
        'musicurl_get': 'method=baidu.ting.song.play&songid=',
        'search': 'method=baidu.ting.search.catalogSug&query=',
        'hot':
        'method=baidu.ting.song.getRecommandSongList&song_id=877578&num=12'
    }

    if text != None:
        if '闹钟' in text:
            clock.start(tok)
        elif '打开' in text:
            sm.cortol('turn_on', text[6:-1], tok)
        elif '关闭' in text:
            sm.cortol('turn_off', text[6:-1], tok)
        elif '获取' in text:
            if '传感器' in text or '温度' in text:
                sm.sensor('sensor', text[6:-1], tok)
            elif '湿度' in text:
                sm.sensor('sensor', text[6:-1], tok)
            else:
                sm.sensor('switch', text[6:-1], tok)
        elif '天气' in text:
            weather.main(tok)
        elif '重新说' in text or '重复' in text:
            speaker.speak()
        elif '翻译' in text:
            ts.main(tok)
        elif '搜索' in text:
            tuling.main(text, tok)
        elif '闲聊' in text:
            tuling.main(text, tok)
        elif '怎么走' in text:
            maps.start(tok)
        elif '酒店' in text:
            tuling.main(text, tok)
        elif '旅游' in text:
            tuling.main(text, tok)
        elif '新闻' in text:
            news.start(tok)
        elif '拍照' in text:
            camera.start(tok)
        elif '邮件' in text or '邮件助手' in text:
            mail.start(tok)
        elif '快递' in text:
            express.start(tok)
        elif '笑话' in text:
            joke.main(tok)
        elif '训练' in text:
            snowboytrain.start(tok)
        elif '播放' in text:
            if '音乐' in text:
                m.sui_ji(services, tok)
            else:
                songname = text[2:-1]
                m.sou_suo(services, songname, tok)
        elif '我想听' in text:
            if '音乐' in text:
                m.sui_ji(services, tok)
            else:
                songname = text[3:-1]
                m.sou_suo(services, songname, tok)
        else:
            tuling.start(text, tok)
    else:
        speaker.speacilrecorder()
Example #16
0
    
    def __init__(self, recentCutoff):
        self.recentCutoff = recentCutoff
        observation_fetcher.fetch()
        self.observationIndex = observation_fetcher.buildIndex()
        self.conditionMgr = condition.buildConditionMgr()

    def update(self, site):
        if recentExistsAlready(Observation, site, self.recentCutoff):
            print "Skipping update of observation for %s" % site.name
            return
        print "Updating observation for %s" % site.name
        nearest = self.observationIndex.getNearest(site.lat, site.lon).next()
        self.saveFullObservation(site, nearest)

    def saveFullObservation(self, site, observation):
        obs, values = observation.toDjangoModels(site, self.conditionMgr)
        obs.save()
        data = ObservationData(observation = obs)
        data.setData(values)
        data.save()


def recentExistsAlready(model, site, recentCutoff):
    recent = model.objects.filter(site_id=site.id, fetch_time__gt=recentCutoff)
    return len(recent) > 0


if __name__ == '__main__':
    main()
while True:

    # "/RECOGOUT"を受信するまで、一回分の音声データを全部読み込む。
    while (string.find(data, "\n.") == -1):
        data = data + sock.recv(1024)

    # 音声XMLデータから、<WORD>を抽出して音声テキスト文に連結する。
    strTemp = ""
    for line in data.split('\n'):
        index = line.find('WORD="')

        if index != -1:
            line = line[index + 6:line.find('"', index + 6)]
            if line != "[s]":
                strTemp = strTemp + line
    if strTemp != "":
        print("結果:" + strTemp)
    if strTemp == "きょうのてんき":  # if you say Hikaregoma, led will turn on
        #os.system('sudo python ~/irmcli/irmcli.py -p -f ~/irmcli/light_on.json')
        weather.main()
    if strTemp == "さいこうきおん":
        #os.system('sudo python ~/irmcli/irmcli.py -p -f ~/irmcli/light_off.json')
        max.main()
    if strTemp == "さいていきおん":
        min.main()
    if strTemp == "いまのきおん":
        now.main()
    #if strTemp == "てれびけして":
    #tv_off.main()
    data = ""
def test_3(monkeypatch):

    monkeypatch.setattr('sys.stdin', airport_name2)

    assert main() != 'no airport found'
Example #19
0
def Meteo():
	Output.insert(END,weather.main())
Example #20
0
def weixin(request):
        print time.time()
        print '-come in--------'
        token = "maixinlong"
        params = request.GET
        args = [token, params['timestamp'], params['nonce']]
        args.sort()
        if hashlib.sha1("".join(args)).hexdigest() == params['signature']:
            if params.has_key('echostr'):
                return HttpResponse(params['echostr'])
            else:
                reply = """<xml><ToUserName><![CDATA[%s]]></ToUserName><FromUserName><![CDATA[%s]]></FromUserName>
                            <CreateTime>%s</CreateTime>
                            <MsgType><![CDATA[text]]></MsgType>
                            <Content><![CDATA[%s]]></Content>
                            <FuncFlag>0</FuncFlag></xml>"""
                if request.raw_post_data:
                    xml = ET.fromstring(request.raw_post_data)
                    content = xml.find("Content").text
                    fromUserName = xml.find("ToUserName").text
                    toUserName = xml.find("FromUserName").text
                    postTime = str(int(time.time()))
                    if not content:
                        return HttpResponse(reply % (toUserName, fromUserName, postTime, "输入点命令吧..."))
                    if content == "Hello2BizUser":
                        return HttpResponse(reply % (toUserName, fromUserName, postTime, "查询成绩绩点请到http://chajidian.sinaapp.com/ 本微信更多功能开发中..."))
                    elif content == "天气":
                        try:
                            city = 'beijing'
                            if cache.get('weather_msg'):
                                weather_msg = cache.get('weather_msg')
                                print 'cache get'
                            else:
                                weather_msg = wea.get_weather_by_city(city)
                                cache.set('weather_msg',weather_msg,60*60*3)
                                print 'cache set.......'
                            return HttpResponse(reply % (toUserName, fromUserName, postTime, weather_msg))
                        except Exception,e:
                            print 'weixin err',e
                            return HttpResponse(reply % (toUserName, fromUserName, postTime, '天气功能开发中...'))
                    elif content == "实时天气":
                        try:
                            temp_list = []
                            weather_msg = weather.main()
                            for k,v in weather_msg.items():
                                temp_list.append(k)
                                temp_list.append(v)
                            weather_msg = ''.join(temp_list)
                            return HttpResponse(reply % (toUserName, fromUserName, postTime, weather_msg))
                        except:
                            return HttpResponse(reply % (toUserName, fromUserName, postTime, '天气功能开发中....'))
                    else:
                        try:
                            rclist = baidu.baidu_search(content)
                            return HttpResponse(reply % (toUserName, fromUserName, postTime, rclist))
                        except Exception,e:
                            return HttpResponse(reply % (toUserName, fromUserName, postTime, e))
                            #return HttpResponse(reply % (toUserName, fromUserName, postTime, "目前只支持查询天气哦(直接输入天气两字),更多:功能开发中...i"))
                    
                else:
                    return HttpResponse("Invalid Request")