Example #1
0
    def __init__(self, sense):
        self.sense = sense
        self.sense.load_image("img/iss.png")

        # Where are you ?
        self.position = location.locate()
        self.position_str = location.geocode(self.position)

        # Stations list
        self.stationList = StationList()
        self.selectStation('ISS (ZARYA)')

        # Print debug info
        # self.printAll()

        # Create root menu and display
        self.menu = Menu0(self)
        self.menu.start()
        self.menu.join()
Example #2
0
# else:
#     api = "google"
# s = places(query, coords[0], api=api)
# s = placeid(s[0]['uid']+","+s[1]['uid'], api=api)
# for i in s[:2]:
#     print i['name'],
#     if 'telephone' in i:
#         print " - ", i['telephone']
#     else:
#         print " - "
# print "="*50

print "test search with yandex api for food in ул. Блохина Санкт-Петербург Россия 197198"
address = ["ул. Блохина", "Санкт-Петербург", "Россия", "197198"]
query = "ресторан"
coords = locate(address)
if geoentry(coords[0])[u'country'][0][1] in apiselect:
    api = apiselect[geoentry(coords[0])[u'country'][0][1]]
else:
    api = "google"
s = places(query, coords[0], api=api, language="ru_RU")
counter = 0
for x in s:
    for j in x:
        try:
            print x[j]['name'], " - ", x[j]['CompanyMetaData']['Phones'][0]['formatted']
            counter += 1
        except:
            pass
    if counter == 2:
        break
Example #3
0
 def country(self):
     return locate(self.ip_address)
Example #4
0
def data2web(province_pin, city_pin, province_han, city_han):
    response = getdata_fromiot(province_pin, city_pin)
    city_instance = Data2web(province_han)
    city_instance.add_city(city_han)
    for state, day, date, air, windspeed, winddirection in data_set(response):
        city_instance.add_state(state)
        city_instance.add_day(day)
        city_instance.add_date(date)
        city_instance.add_air(air)
        city_instance.add_windspeed(windspeed)
        city_instance.add_winddirection(winddirection)
    return city_instance()


# 定位、初始化
myprovince_han, mycity_han = locate()
data = initial(myprovince_han, mycity_han)
MC = MemClient()
MC.set(myprovince_han + mycity_han, data)


class MainHandler(tornado.web.RequestHandler):
    def get(self):
        self.render('index.html')

    def post(self, *args, **kwargs):
        print(data)
        self.write(data)


class ChangeHandler(tornado.web.RequestHandler):
Example #5
0
def assistant(command):
    if 'shutdown' in command:
        mavis_response('Bye bye Sir. Have a nice day')
        sys.exit()
    elif 'close' in command:
        Exe = command.split('close')
        Exe = Exe[1] + '.exe'
        os.system("taskkill /f /im " + Exe)
    elif 'launch' in command:
        name = command.split('launch ')
        mavis_response('launching' + name[1])
        name = name[1] + '.exe'
        file_path = fd.file_equal_search(name)
        os.startfile(file_path)
    elif 'Wikipedia' in command:
        query = command.split("for ")
        query = query[1]
        try:

            mavis_response('Searching Wikipedia for ' + query)
            results = wikipedia.summary(query, sentences=2)
            print(results, sep='.')
            mavis_response("According to Wikipedia")
            mavis_response(results)
        except exceptions.DisambiguationError as error:
            mavis_response("Disambiguition while searching for " + query)
            mavis_response(query + ' may refer to one of the following ')
            for i in range(len(error.options)):
                print(error.options[i])
                mavis_response(error.options[i])
            pass
    elif 'list programs' in command:
        mavis_response('Wait. Scanning your device')
        app_list.list()
        mavis_response('These are all the installed programs')

    elif 'search for' in command:
        search = command.split('for ')
        search = search[1]
        url = 'https://www.google.com/search?q=' + search
        results = wikipedia.summary(search, sentences=2)
        webbrowser.open(url)
        mavis_response("results are opened in the browser")
        mavis_response("According to Wikipedia " + results)
    elif 'play music' in command:
        music_dir = 'C:/Users/Sachin Namdeo/Desktop/music'
        songs = os.listdir(music_dir)
        num = random.randint(0, len(songs))
        os.startfile(os.path.join(music_dir, songs[num]))
    elif 'play' in command:
        search = command.split('play ')
        search = search[1]
        query_string = urllib.parse.urlencode({"search_query": search})
        html_content = urllib.request.urlopen(
            "http://www.youtube.com/results?" + query_string)
        search_results = re.findall(r'href=\"\/watch\?v=(.{11})',
                                    html_content.read().decode())
        webbrowser.open("http://www.youtube.com/watch?v=" + search_results[0])
    elif 'open' in command and 'file' in command:
        if 'Word' in command:
            name = command.split('open Word file ')
            name = name[1] + '.docx'
            path = fd.file_search(name)
            os.startfile(path)
        elif 'PPT' in command:
            name = command.split('open PPT file ')
            name = name[1] + '.pptx'
            path = fd.file_search(name)
            os.startfile(path)
        elif 'PDF' in command:
            name = command.split('open PDF file ')
            name = name[1] + '.pdf'
            path = fd.file_search(name)
            os.startfile(path)
        elif 'Rar' in command:
            name = command.split('open Rar file ')
            name = name[1] + '.rar'
            path = fd.file_search(name)
            os.startfile(path)

    elif 'open website' in command:
        site = command.split('open website ')
        site = site[1]
        url = 'https://www.' + site
        webbrowser.open(url)
        mavis_response('opening ' + site)

    elif 'current weather' in command:
        location = loc.locate()
        apikey = 'YOUR-API-KEY'
        lat = location[0]
        lng = location[1]
        response = ForecastIO.ForecastIO(
            apikey,
            units=ForecastIO.ForecastIO.UNITS_SI,
            lang=ForecastIO.ForecastIO.LANG_ENGLISH,
            latitude=lat,
            longitude=lng)
        currently = FIOHourly.FIOHourly(response)
        print(loc.place() + ' has ' + currently.get()['summary'])
        mavis_response(loc.place() + ' has ' + currently.get()['summary'])

    elif 'time' in command:
        now = datetime.datetime.now()
        mavis_response('Current time is %d hours %d minutes' %
                       (now.hour, now.minute))
Example #6
0
 def country(self):
     return locate(self.ip_address)