Пример #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' % oa.util.legacy.bytes2gb(
        oa.util.legacy.sys.free_memory())

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

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

    say(response)
Пример #2
0
def calculate():
    ret = expr2str()
    info(oa.util.legacy.op.sys.expr)
    info('expr=' + ret)
    try:
        say(eval(ret))
    except:
        say('Error. Wrong expression. ' + ret)
    # Clear the expression.
    oa.util.legacy.sys.expr = []
Пример #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
Пример #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)
Пример #5
0
def list_commands():
    say('- The currently available voice commands are:\n{}'.format(',\n'.join(
        kws.keys())))
Пример #6
0
def hello_world():
    say('- Hello world!')
Пример #7
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
Пример #8
0
def say_last_command(string=''):
    say(string + ' ' + oa.util.legacy.oa.last_command)
Пример #9
0
def say_day():
    """ Speak the current day. """
    day = oa.util.legacy.sys.day_name()
    say('- Today is %s.' % day)
Пример #10
0
def say_time():
    """ Speak the current time. """
    time = oa.util.legacy.sys.time_text()
    say('- The time is %s.' % time)
Пример #11
0
def list_commands():
    say('The currently available voice commands are..')
    [say(cmd) for cmd in kws.keys()]