示例#1
0
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)
示例#2
0
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)
示例#3
0
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)
示例#4
0
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)
示例#5
0
 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")
示例#6
0
 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")
示例#7
0
文件: chatting.py 项目: YugantM/rough
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)
示例#8
0
"""Main module, calls command.main()"""

__version__ = "$Revision: 472 $"
__author__ = "Joel R. Mitchelson"

import command

command.main()
示例#9
0
from command import main

if __name__ == '__main__':
    main()