Example #1
0
def main():
	try:
		command = request.args.get("command", '')
		logs.write("Command is {0}".format(command),'working')
		logs.write("Analyzing content in command", 'trying')
		contentextract.main(command)
		logs.write("Analyzed command content", 'success')
		logs.write("Trying to load plugin modules", 'trying')
		plugins=plugs.load()
		if plugins==False:
			logs.write("Could not load plugins", 'error')
			return "error"
		elif plugins==[]:
			logs.write("No plugins found", 'error')
			return 'error'
		logs.write("Successfully loaded plugin modules", 'success')
		logs.write("Using the intent module to parse the command", 'trying')
		parsed=intent.parse(command, plugins)
		logs.write("Parsed the command", 'success')
		if parsed.keys()[0]=="execute":
			logs.write("Executing plugin {0}".format(parsed.values()[0].keys()[0]), 'trying')
			response=plugs.execute(parsed.values()[0], command)
			logs.write("Found answer {0}, returning it".format(response), 'success')
			return response
	except Exception as e:
		logs.write(e,'error')
		return str(e)
Example #2
0
def main():
    try:
        command = request.args.get("command", '')
        logs.write("Command is {0}".format(command), 'working')
        logs.write("Analyzing content in command", 'trying')
        contentextract.main(command)
        logs.write("Analyzed command content", 'success')
        logs.write("Trying to load plugin modules", 'trying')
        plugins = plugs.load()
        if plugins == False:
            logs.write("Could not load plugins", 'error')
            return "error"
        elif plugins == []:
            logs.write("No plugins found", 'error')
            return 'error'
        logs.write("Successfully loaded plugin modules", 'success')
        logs.write("Using the intent module to parse the command", 'trying')
        parsed = intent.parse(command, plugins)
        logs.write("Parsed the command", 'success')
        if parsed.keys()[0] == "execute":
            logs.write(
                "Executing plugin {0}".format(parsed.values()[0].keys()[0]),
                'trying')
            response = plugs.execute(parsed.values()[0], command)
            logs.write("Found answer {0}, returning it".format(response),
                       'success')
            return response
    except Exception as e:
        logs.write(e, 'error')
        return str(e)
Example #3
0
def main():
	'''Take command from 127.0.0.1:5000 and run it through various modules'''
	try:
		#Get command
		command = request.args.get("command", '')
		logs.write("Command is {0}".format(command),'working')
		logs.write("Analyzing content in command", 'trying')
		#Run command through contentextract.py
		contentextract.main(command)
		logs.write("Analyzed command content", 'success')
		logs.write("Trying to load plugin modules", 'trying')
		#Load plugins using plugins.py
		plugins=plugs.load()
		#If the plugins encounter an error
		if plugins==False:
			logs.write("Could not load plugins", 'error')
			return "error"
		#If plugins.py says that there are no plugins found. All functions are a plugin so no point in continuing
		elif plugins==[]:
			logs.write("No plugins found", 'error')
			return 'error'
		logs.write("Successfully loaded plugin modules", 'success')
		logs.write("Using the intent module to parse the command", 'trying')
		#Use intent.py to try to extract intent from command
		parsed=intent.parse(command, plugins)
		logs.write("Parsed the command", 'success')
		#If the intent parser says to execute the following plugin. Leaves room if I ever want to expand the capabilities of the intent module
		if parsed.keys()[0]=="execute":
			logs.write("Executing plugin {0}".format(parsed.values()[0].keys()[0]), 'trying')
			response=plugs.execute(parsed.values()[0], command)
			logs.write("Found answer {0}, returning it".format(response), 'success')
			return response
	except Exception as e:
		logs.write(e,'error')
		return str(e)
Example #4
0
def main():
    '''Take command from 127.0.0.1:5000 and run it through various modules'''
    try:
        # Get command
        command = request.args.get("command", '')
        log.debug("Command is {0}".format(command))
        log.info("Analyzing content in command")
        # Run command through contentextract.py
        contentextract.main(command)
        log.info("Analyzed command content")
        log.info("Trying to load plugin modules")
        # Load plugins using plugins.py
        plugins = plugs.load()
        # If the plugins encounter an error
        if plugins is False:
            log.error("Could not load plugins")
            return "error"
        # If plugins.py says that there are no plugins found. All functions are
        # a plugin so no point in continuing
        elif plugins == []:
            log.error("No plugins found")
            return 'error'
        log.info("Successfully loaded plugin modules")
        log.info("Using the intent module to parse the command")
        # Use intent.py to try to extract intent from command
        parsed = intent.parse(command, plugins)
        log.info("Parsed the command")
        # If the intent parser says to execute the following plugin. Leaves
        # room if I ever want to expand the capabilities of the intent module
        if parsed.keys()[0] == "execute":
            log.info("Executing plugin {0}".format(
                parsed.values()[0].keys()[0]))
            response = plugs.execute(parsed.values()[0], command)
            log.info("Found answer {0}, returning it".format(
                response))
            return response
        elif parsed.keys()[0]=="error":
            log.error("Parse function returned the error {0}".format(parsed.values()[0]))
            if parsed.values()[0]=="notfound":
                #This would have unhandled exceptions if the search plugin was gone, but I can't imagine why it would be
                log.error("The error means that the command was not recognized")
                log.info("Using the search plugin on the command phrase")
                log.info("Trying to find search plugin")
                for plugin in plugins:
                    if plugin.keys()[0]=="search":
                        searchplug=plugin
                        break
                log.info("Found search plugin")
                response=plugs.execute(searchplug,command)
                log.info("Found answer {0}, returning it".format(response))
                return response
            else:
                log.error("Unhandled error {0}. If you get this error message something is broken in the intent module. Please raise an issue on https://github.com/ironman5366/W.I.L.L".format(str(parsed.values()[0])))
    except Exception as e:
        log.error(e, 'error')
        return str(e)
Example #5
0
def main():
    '''Take command from 127.0.0.1:5000 and run it through various modules'''
    try:
        #Get command
        command = request.args.get("command", '')
        logs.write("Command is {0}".format(command), 'working')
        logs.write("Analyzing content in command", 'trying')
        #Run command through contentextract.py
        contentextract.main(command)
        logs.write("Analyzed command content", 'success')
        logs.write("Trying to load plugin modules", 'trying')
        #Load plugins using plugins.py
        plugins = plugs.load()
        #If the plugins encounter an error
        if plugins == False:
            logs.write("Could not load plugins", 'error')
            return "error"
        #If plugins.py says that there are no plugins found. All functions are a plugin so no point in continuing
        elif plugins == []:
            logs.write("No plugins found", 'error')
            return 'error'
        logs.write("Successfully loaded plugin modules", 'success')
        logs.write("Using the intent module to parse the command", 'trying')
        #Use intent.py to try to extract intent from command
        parsed = intent.parse(command, plugins)
        logs.write("Parsed the command", 'success')
        #If the intent parser says to execute the following plugin. Leaves room if I ever want to expand the capabilities of the intent module
        if parsed.keys()[0] == "execute":
            logs.write(
                "Executing plugin {0}".format(parsed.values()[0].keys()[0]),
                'trying')
            response = plugs.execute(parsed.values()[0], command)
            logs.write("Found answer {0}, returning it".format(response),
                       'success')
            return response
    except Exception as e:
        logs.write(e, 'error')
        return str(e)
Example #6
0
def handleInput():
    sentence = input('>>> ')
    nlu_result = intent.parse(sentence)
    return nlu_result