def diagnostics(): """ Run system diagnostics. """ response = 'Lancement des diagnostiques... ' # Processor Temperature. if hasattr(psutil, "sondes_de_temperatures"): temps = psutil.sensors_temperatures() if not temps: response += "Impossible de lire la temperature.\n" else: for name, entries in temps.items(): for entry in entries: response += 'La temperature du proccesseur est actuellement de %.0f degrés centigrade...\n' %entry.current break break # Memory Free. response += 'La memoire système est a %.0f Gigaoctet de libre...\n' %bytes2gb(oa.sys.free_memory()) # Drive Space Free. response += 'Le disque dur interne est libre a %.0f Gigaoctet...\n' %bytes2gb(psutil.disk_usage('/').free) # Network Status. response += switch(is_online(), True, 'L\'accès à Internet est opérationnel.', 'Nous sommes hors-ligne.') say(response)
def diagnostics(): """ Run system diagnostics. """ response = '- Running diagnostics... ' # Processor Temperature. if hasattr(psutil, "sensors_temperatures"): temps = psutil.sensors_temperatures() if not temps: response += "Unable to read temperature.\n" else: for name, entries in temps.items(): for entry in entries: response += 'Proccessor temperature is currently %.0f degrees Centegrade...\n' % entry.current break break # Memory Free. response += 'System memory has %.0f Gigabytes free...\n' % oa.legacy.bytes2gb( oa.legacy.sys.free_memory()) # Drive Space Free. response += 'Internal hard drive has %.0f Gigabytes free...\n' % oa.legacy.bytes2gb( psutil.disk_usage('/').free) # Network Status. response += oa.legacy.switch(is_online(), True, 'Internet access is currently available.', 'We are offline.') say(response)
def bulb_turn_off(): if bulb: asyncio.run(bulb.update()) if bulb.is_off == True: say("But it's already turn off. Nothing to be done.") else: asyncio.run(bulb.turn_off())
def m_info(): try: meta = media_getmetadata() title = meta[dbus.String('xesam:title')] album = meta[dbus.String('xesam:album')] artist = meta[dbus.String('xesam:artist')][0] say("Currently playing" + title + ", from album " + album + ", by" + artist) except: say("no media players detected")
def calculate(): ret = expr2str() info(oa.sys.expr) info('expr=' + ret) try: say(eval(ret)) except: say('Error. Wrong expression. ' + ret) # Clear the expression. oa.sys.expr = []
def read_news_feed(news_feed, category): rss = feedparser.parse(news_feed) info(rss['feed']['title']) say('Lecture de l\'actualité %s.' %category) headline_count = 1 # Amount of headlines to read. headline_amount = 5 for post in rss.entries: if(headline_count == headline_amount): break else: headline = post.title exclude = set(string.punctuation) headline = ''.join(ch for ch in headline if ch not in exclude) say(headline) headline_count += 1
def read_forecast(): import forecastio """ Get the weather forecast from Dark Sky (darksky.net). Get your API key and longitude / latitude at: https://darksky.net/dev/ Install 'forecastio' module with: `pip install python-forcastio` """ # Weather For Amberg, Germany. api_key = "e3f8667cb539171dc2f4b389d33648ce" lat = 47.409342 lng = 0.681183 forecast = forecastio.load_forecast(api_key, lat, lng, lang='fr') byNow = forecast.currently() byHour = forecast.hourly() byDay = forecast.daily() weather_summary = """La météo actuelle est %s.\n La temperature est de %d degrés Celsius.\n %s \n %s""" %(byNow.summary, int(byNow.temperature),byHour.summary,byDay.summary) say(weather_summary)
def read_forecast(): import forecastio """ Get the weather forecast from Dark Sky (darksky.net). Get your API key and longitude / latitude at: https://darksky.net/dev/ Install 'forecastio' module with: `pip install python-forcastio` """ # Weather For Amberg, Germany. api_key = "e3f8667cb539171dc2f4b389d33648ce" lat = 49.44287 lng = 11.86267 forecast = forecastio.load_forecast(api_key, lat, lng, lang='en') byNow = forecast.currently() byHour = forecast.hourly() byDay = forecast.daily() weather_summary = """ - The weather is currently %s.\n The temperature is %d degrees Celsius.\n %s \n %s""" % ( byNow.summary, int(byNow.temperature), byHour.summary, byDay.summary) say(weather_summary)
def bulb_color_green(): if bulb.is_on == False: say("Please turn on the lights first.") else: bulb.hsv = (120, 75, 100)
def swiper(): say("ohhh! maaan!") mind('boot')
def thank_you(): say("you're welcome, f****r")
def say_day(): """ Speak the current day. """ day = oa.legacy.sys.day_name() say('- Today is %s.' % day)
def bulb_color_yellow(): if bulb.is_on == False: say("Please turn on the lights first.") else: bulb.color_temp = 2500 bulb.hsv = (0, 0, 100)
def bulb_turn_on(): if bulb.is_on == True: say("But It's already turn on. Nothing to be done.") else: bulb.turn_on()
def bulb_color_white(): if bulb.is_on == False: say("Please turn on the lights first.") else: bulb.color_temp = (9000)
def open_root(): #play('beep_open.wav') say('Whats up?') mind('root')
def say_last_command(string = ''): say(string + ' ' + oa.last_command)
def say_day(): """ Speak the current day. """ day = oa.sys.day_name() say('Nous sommes aujourd\'hui le %s.' %day)
def say_time(): """ Speak the current time. """ time = oa.sys.time_text() say('Il est %s.' %time)
def list_commands(): say('The currently available voice commands are..') [say(cmd) for cmd in kws.keys()]
def bulb_color_purple(): if bulb.is_on == False: say("Please turn on the lights first.") else: bulb.hsv = (259, 75, 100)
def hello_world(): say('- Hello world!')
def bulb_color_pink(): if bulb.is_on == False: say("Please turn on the lights first.") else: bulb.hsv = (301, 79, 100)
def hello_world(): say('Hi William')
def bulb_color_lime(): if bulb.is_on == False: say("Please turn on the lights first.") bulb.hsv = (106, 48, 100)
def who(): say('Hi William, this is elsa')
def bulb_turn_off(): if bulb.is_off == True: say("But it's already turn off. Nothing to be done.") else: bulb.turn_off()
def list_commands(): say('- The currently available voice commands are:\n{}'.format(',\n'.join(kws.keys())))
def close(s): """ Close an application by a window or process name. A partial window name will work, for example: 'note*'. """ say('- Unable to close %s for now.' % s) pass
def say_time(): """ Speak the current time. """ time = oa.legacy.sys.time_text() say('- The time is %s.' % time)