Esempio n. 1
0
def listen(command):
    path.append("../")
    from olga import makeOOO
    output = None
    if (command == "arm"):
        try:
            # arm system
            threadFile = open("threads.data", "r")
            threadData = []
            for line in threadFile.readlines():
                print(line)
                for s in line[:].split(':'):
                    print(s)
                    threadData.append(s)

            if (threadData[1] == "True"):
                output = makeOOO(text="Watchdog service already running.")
                return output

            threadFile.close()
            threadFile = open("threads.data", "w")

            watchdogThread = threading.Thread(target=watchdog)
            watchdogThread.daemon = True
            watchdogThread.start()

            threadFile.write("watchdog:True")
            threadFile.close()

            output = makeOOO(text="System Armed.")
        except Exception as e:
            print(e)
            output = makeOOO(text="You're a failure.")
            pass

    elif (command == "disarm"):
        try:
            # disarm system
            threadFile = open("threads.data", "r")
            threadData = []
            for line in threadFile.readlines():
                for s in line[:].split(':'):
                    threadData.append(s)

            if (threadData[1] == "False"):
                output = makeOOO(text="Watchdog service already shutdown.")
                return output

            threadFile.close()

            threadFile = open("threads.data", "w")
            threadFile.write("watchdog:False")
            threadFile.close()

            output = makeOOO(text="System Disarmed.")
        except Exception as e:
            print(e)
            output = makeOOO(text="You're a failure.")

    return output
Esempio n. 2
0
def listen(command):
    # Takes and processes command from OLGA

    # Adds olga's directory to be accessible
    import os
    olgaDir = os.getcwd().replace("Extensions" + os.sep, "")
    path.append(olgaDir)
    from olga import makeOOO

    # Package output into an Olga Output Object
    output = None
    if (command == "hello"):
        output = makeOOO(text="Hello World")
    return output
Esempio n. 3
0
def listen(command):
    # Takes and processes command from OLGA
    
    # Adds olga's directory to be accessible
    import os
    olgaDir = os.getcwd().replace("Extensions"+os.sep, "")
    path.append(olgaDir)
    from olga import makeOOO
    
    # Package output into an Olga Output Object
    output = None
    if(command=="word"):
        output = makeOOO(text="Open Microsoft Word")
        import subprocess
        subprocess.Popen('C:\\Program Files (x86)\\\Microsoft Office\\root\\Office16\\WINWORD') # This opens up the calculator
    return output
Esempio n. 4
0
def listen(command):
    # Takes and processes command from OLGA
    
    # Adds olga's directory to be accessible
    import os
    olgaDir = os.getcwd().replace("Extensions"+os.sep, "")
    path.append(olgaDir)
    from olga import makeOOO
    
    # Package output into an Olga Output Object
    output = None
    if(command=="itunes"):
        output = makeOOO(text="Open Itunes")
        import subprocess
        subprocess.Popen('C:\\Program Files\\iTunes\\itunes.exe') # This opens up the calculator
    return output
Esempio n. 5
0
def listen(command):
    # Takes and processes command from OLGA

    # Adds olga's directory to be accessible
    import os
    olgaDir = os.getcwd().replace("Extensions" + os.sep, "")
    path.append(olgaDir)
    from olga import makeOOO

    # Package output into an Olga Output Object
    output = None
    if (command == "insta"):
        search = ""
        category = input("Choose Hashtag (H) or Username (U): ")
        if (category == "h" | category == "H"):
            search = input("Enter a hashtag: #")
            OLGAWebScrapeExt(category, search)
        elif (category == "u" | category == "U"):
            search = input("Enter a username: www.instagram.com/")
            OLGAWebScrapeExt(category, search)
        output = makeOOO(text="Success")
    return output
Esempio n. 6
0
def listen(command):
    scope = 'user-read-private user-read-playback-state user-modify-playback-state'
    username = "******"
    track = command.replace("play ","")

    import os
    # Check if there is a spotify token file
    if (os.path.exists(f".pickle--{username}")):
        spotify = pickle.load(open( f".pickle--{username}", "rb" ))
    else:
        token = util.prompt_for_user_token(username, scope, client_id="", client_secret="", redirect_uri="https://localhost/")
        # Generate request (before API)
        spotify = spotipy.Spotify(auth=token)
        pickle.dump(spotify, open( f".pickle--{username}", "wb" ) ) # thats hot :fire:

    # Get the response (after API)
    # Look through devices
    devices = spotify.devices()
    print(json.dumps(devices, sort_keys=True, indent=4))
    deviceId = devices['devices'][0]['id']

    # Play/edit/change music
    tids = [] 
    results =spotify.search(q=track, limit=1, type='track') 
    for i, t in enumerate(results['tracks']['items']):
        tids.append(t['uri'])
    spotify.start_playback(deviceId, None, tids, None)

    # Adds olga's directory to be accessible
    import os
    olgaDir = os.getcwd().replace("Extensions"+os.sep, "")
    sys.path.append(olgaDir)
    from olga import makeOOO
    
    # Package output into an Olga Output Object
    output = makeOOO(text="Success")

    return output
Esempio n. 7
0
def listen(command):
    try:
        # Takes and processes command from OLGA

        # Adds olga's directory to be accessible
        import os
        olgaDir = os.getcwd().replace("Extensions" + os.sep, "")
        path.append(olgaDir)
        from olga import makeOOO

        # Need to get the most current weather.
        owm = OWM(TOKEN)
        observation = owm.weather_at_place('Kent,US')
        w = observation.get_weather()

        # Package output into an Olga Output Object
        output = None
        if (command == "temperature"):
            output = makeOOO(
                text=str(w.get_temperature('fahrenheit')['temp']) +
                ' F Date/Time:' + str(w.get_reference_time(timeformat='iso')))
        elif (command == "clouds"):
            output = makeOOO(text=str(w.get_clouds()) +
                             "% Cloud Cover. Date/Time:" +
                             str(w.get_reference_time(timeformat='iso')))
        elif (command == "pressure"):
            output = makeOOO(text=str(w.get_pressure()) + " Date/Time:" +
                             str(w.get_reference_time(timeformat='iso')))
        elif (command == "humidity"):
            output = makeOOO(text=str(w.get_humidity()) +
                             "% Humidity. Date/Time:" +
                             str(w.get_reference_time(timeformat='iso')))
        elif (command == "summary"):
            output = makeOOO(text=str(w.get_status()))
        elif (command == "detailed_summary"):
            output = makeOOO(text=w.get_detailed_status())
        return output
    except:
        output = makeOOO(error="Internet is required sweetheart...")
    return output