Exemplo n.º 1
0
 def handle_execute_from_shell(self, cmd_line):
     """
     Handles all commands that take a filename and 0 or more extra arguments.
     Passes the command to backend.
     
     (Debugger plugin may also use this method)
     """
     command, args = parse_shell_command(cmd_line)
     
     if len(args) >= 1:
         get_workbench().get_editor_notebook().save_all_named_editors()
         cmd = ToplevelCommand(command=command,
                            filename=args[0],
                            args=args[1:])
         
         if os.path.isabs(cmd.filename):
             cmd.full_filename = cmd.filename
         else:
             cmd.full_filename = os.path.join(self.get_cwd(), cmd.filename)
             
         if command in ["Run", "run", "Debug", "debug"]:
             with tokenize.open(cmd.full_filename) as fp:
                 cmd.source = fp.read()
             
         self.send_command(cmd)
     else:
         raise CommandSyntaxError("Command '%s' takes at least one argument", command)
Exemplo n.º 2
0
def _handle_rundebug_from_shell(cmd_line):
    """
    Handles all commands that take a filename and 0 or more extra arguments.
    Passes the command to backend.

    (Debugger plugin may also use this method)
    """
    command, args = parse_shell_command(cmd_line)

    if len(args) >= 1:
        get_workbench().get_editor_notebook().save_all_named_editors()

        origcommand=command
        if command == "Ev3RemoteRun":
            command="Run"
        if command == "Ev3RemoteDebug":
            command="Debug"

        cmd = ToplevelCommand(command=command,
                              filename=args[0],
                              args=args[1:])

        if origcommand == "Ev3RemoteRun" or origcommand == "Ev3RemoteDebug":
            cmd.environment={ "EV3MODE" : "remote", "EV3IP": get_workbench().get_option("ev3.ip") }

        if os.path.isabs(cmd.filename):
            cmd.full_filename = cmd.filename
        else:
            runner=get_runner()
            cmd.full_filename = os.path.join(runner.get_cwd(), cmd.filename)

        if command in ["Run", "run", "Debug", "debug"]:
            with tokenize.open(cmd.full_filename) as fp:
                cmd.source = fp.read()

        get_runner().send_command(cmd)
    else:

        print_error_in_backend("Command '{}' takes at least one argument".format(command))