def call(cline, env, cwd, loc, cb, context, echo, justprint=False): executable, argv = prepare_command(cline, cwd, loc) if not len(argv): cb(res=0) return if argv[0] == command.makepypath: command.main(argv[1:], env, cwd, cb) return if argv[0:2] == [ sys.executable.replace('\\', '/'), command.makepypath.replace('\\', '/') ]: command.main(argv[2:], env, cwd, cb) return context.call(argv, executable=executable, shell=False, env=env, cwd=cwd, cb=cb, echo=echo, justprint=justprint)
def call(cline, env, cwd, loc, cb, context, echo, justprint=False): #TODO: call this once up-front somewhere and save the result? shell, msys = util.checkmsyscompat() shellreason = None if msys and cline.startswith('/'): shellreason = "command starts with /" else: argv, badchar = clinetoargv(cline) if argv is None: shellreason = "command contains shell-special character '%s'" % ( badchar, ) elif len(argv) and argv[0] in shellwords: shellreason = "command starts with shell primitive '%s'" % ( argv[0], ) if shellreason is not None: _log.debug("%s: using shell: %s: '%s'", loc, shellreason, cline) if msys: if len(cline) > 3 and cline[1] == ':' and cline[2] == '/': cline = '/' + cline[0] + cline[2:] cline = [shell, "-c", cline] context.call(cline, shell=not msys, env=env, cwd=cwd, cb=cb, echo=echo, justprint=justprint) return if not len(argv): cb(res=0) return if argv[0] == command.makepypath: command.main(argv[1:], env, cwd, cb) return if argv[0:2] == [ sys.executable.replace('\\', '/'), command.makepypath.replace('\\', '/') ]: command.main(argv[2:], env, cwd, cb) return if argv[0].find('/') != -1: executable = util.normaljoin(cwd, argv[0]) else: executable = None context.call(argv, executable=executable, shell=False, env=env, cwd=cwd, cb=cb, echo=echo, justprint=justprint)
def call(cline, env, cwd, loc, cb, context, echo, justprint=False): #TODO: call this once up-front somewhere and save the result? shell, msys = util.checkmsyscompat() shellreason = None if msys and cline.startswith('/'): shellreason = "command starts with /" else: argv, badchar = clinetoargv(cline, blacklist_gray=True) if argv is None: shellreason = "command contains shell-special character '%s'" % (badchar,) elif len(argv) and argv[0] in shellwords: shellreason = "command starts with shell primitive '%s'" % (argv[0],) else: argv = doglobbing(argv, cwd) if shellreason is not None: _log.debug("%s: using shell: %s: '%s'", loc, shellreason, cline) if msys: if len(cline) > 3 and cline[1] == ':' and cline[2] == '/': cline = '/' + cline[0] + cline[2:] cline = [shell, "-c", cline] context.call(cline, shell=False, env=env, cwd=cwd, cb=cb, echo=echo, justprint=justprint) return if not len(argv): cb(res=0) return if argv[0] == command.makepypath: command.main(argv[1:], env, cwd, cb) return if argv[0:2] == [sys.executable.replace('\\', '/'), command.makepypath.replace('\\', '/')]: command.main(argv[2:], env, cwd, cb) return if argv[0].find('/') != -1: executable = util.normaljoin(cwd, argv[0]) else: executable = None context.call(argv, executable=executable, shell=False, env=env, cwd=cwd, cb=cb, echo=echo, justprint=justprint)
def call(cline, env, cwd, loc, cb, context, echo, justprint=False): executable, argv = prepare_command(cline, cwd, loc) if not len(argv): cb(res=0) return if argv[0] == command.makepypath: command.main(argv[1:], env, cwd, cb) return if argv[0:2] == [sys.executable.replace('\\', '/'), command.makepypath.replace('\\', '/')]: command.main(argv[2:], env, cwd, cb) return context.call(argv, executable=executable, shell=False, env=env, cwd=cwd, cb=cb, echo=echo, justprint=justprint)
def test_expected_output(self, mock_stdout): command.main(["PLACE 0,0,NORTH", "MOVE", "REPORT"], 5, 5) self.assertEqual(mock_stdout.getvalue(), "0,1,NORTH\n")
def test_expected_output2(self, mock_stdout): command.main( ["PLACE 1,2,EAST", "MOVE", "MOVE", "LEFT", "MOVE", "REPORT"], 5, 5) self.assertEqual(mock_stdout.getvalue(), "3,3,NORTH\n")
from chatterbot.trainers import ListTrainer import nltk import csv import os import command import pickle with open('chat.csv', 'r') as f: reader = csv.reader(f) your_list = list(reader) jarvis = ChatBot("JARVIS") jarvis.set_trainer(ListTrainer) #y = jarvis.train(your_list) #pickle.dump(y, open( "jarvis_bot.p", "wb" ) ) que = "who are you" response = jarvis.get_response(que) #print(response) #print(response.text.find('command')) if (response.text.find('command') > 0): print(command.main(que)) else: print(response)
"""Main module, calls command.main()""" __version__ = "$Revision: 472 $" __author__ = "Joel R. Mitchelson" import command command.main()
from command import main if __name__ == '__main__': main()