pymel.core.general.commandPort

commandPort(*args, **kwargs)

Opens or closes the Maya command port. The command port comprises a socket to which a client program may connect. An example command port client mcpis included in the Motion Capture developers kit. It supports multi-byte commands and uses utf-8 as its transform format. It will receive utf8 command string and decode it to Maya native coding. The result will also be encoded to utf-8 before sending back. Care should be taken regarding INET domain sockets as no user identification, or authorization is required to connect to a given socket, and all commands (including system(...)) are allowed and executed with the user id and permissions of the Maya user. The prefix flag can be used to reduce this security risk, as only the prefix command is executed. The query flag can be used to determine if a given command port exists. See examples below.

Flags:
  • bufferSize : bs (int) [create]

    Commands and results are each subject to size limits. This option allows the user to specify the size of the buffer used to communicate with Maya. If unspecified the default buffer size is 4096 characters. Commands longer than bufferSize characters will cause the client connection to close. Results longer that bufferSize characters are replaced with an error message.

  • close : cl (bool) [create]

    Closes the commandPort, deletes the pipes

  • echoOutput : eo (bool) [create]

    Sends a copy of all comand output to the command port. Typically only the result is transmitted. This option provides a copy of all output.

  • listPorts : lp (bool) []

  • name : n (unicode) [create]

    Specifies the name of the command port which this command creates. CommandPort names of the form namecreate a UNIX domain socket on the localhost corresponding to name. If namedoes not begin with /, then /tmp/nameis used. If namebegins with /, namedenotes the full path to the socket. Names of the form :port numbercreate an INET domain on the local host at the given port.

  • noreturn : nr (bool) [create]

    Do not write the results from executed commands back to the command port socket. Instead, the results from executed commands are written to the script editor window. As no information passes back to the command port client regarding the execution of the submitted commands, care must be taken not to overflow the command buffer, which would cause the connection to close.

  • pickleOutput : po (bool) [create]

    Python output will be pickled. Flag can have multiple arguments, passed either as a tuple or a list.

  • prefix : pre (unicode) [create]

    The string argument is the name of a Maya command taking one string argument. This command is called each time data is sent to the command port. The data written to the command port is passed as the argument to the prefix command. The data from the command port is encoded as with enocodeString and enclosed in quotes. If newline characters are embedded in the command port data, the input is split into individual lines. These lines are treated as if they were separate writes to the command port. Only the result to the last prefix command is returned.

  • returnNumCommands : rnc (bool) [create]

    Ignore the result of the command, but return the number of commands that have been read and executed in this call. This is a simple way to track buffer overflow. This flag is ignored when the noreturnflag is specified.

  • securityWarning : sw (bool) [create]

    Enables security warning on command port input.

  • sourceType : stp (unicode) [create]

    The string argument is used to indicate which source type would be passed to the commandPort, like mel, python. The default source type is mel.

Derived from mel command maya.cmds.commandPort

Previous topic

pymel.core.general.commandEcho

Next topic

pymel.core.general.condition

Core

Core Modules

Other Modules

This Page