Exemple #1
0
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' %bytes2gb(oa.sys.free_memory)

    # Drive Space Free.
    response += 'Internal hard drive has %.0f Gigabytes free...\n' %bytes2gb(psutil.disk_usage('/').free)

    # Network Status.
    response += switch(is_online(), True, 'Internet access is currently available.', 'We are offline.')

    say(response)
Exemple #2
0
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 = []
Exemple #3
0
def read_news_feed(news_feed, category):
    rss = feedparser.parse(news_feed)
    info(rss['feed']['title'])
    say('- Reading %s news.' %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
Exemple #4
0
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)
Exemple #5
0
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
Exemple #6
0
def list_commands():
    say('The currently available voice commands are..')
    [say(cmd) for cmd in kws.keys()]
Exemple #7
0
def list_commands():
    say('- The currently available voice commands are:\n{}'.format(',\n'.join(
        kws.keys())))
Exemple #8
0
def hello_world():
    say('- Hello world!')
Exemple #9
0
def say_last_command(string = ''):
    say(string + ' ' + oa.last_command)
Exemple #10
0
def say_day():
    """ Speak the current day. """
    day = oa.sys.day_name
    say('- Today is %s.' %day)
Exemple #11
0
def say_time():
    """ Speak the current time. """
    time = oa.sys.time_text()
    say('- The time is %s.' %time)