Logo Search packages:      
Sourcecode: kayali version File versions  Download package

def pexpect::spawn::__init__ (   self,
  command,
  args = [],
  timeout = 30 
)

This is the constructor. The command parameter may be a string
that includes a command and any arguments to the command. For example:
    p = pexpect.spawn ('/usr/bin/ftp')
    p = pexpect.spawn ('/usr/bin/ssh user@example.com')
    p = pexpect.spawn ('ls -latr /tmp')
You may also construct it with a list of arguments like so:
    p = pexpect.spawn ('/usr/bin/ftp', [])
    p = pexpect.spawn ('/usr/bin/ssh', ['user@example.com'])
    p = pexpect.spawn ('ls', ['-latr', '/tmp'])
After this the child application will be created and
will be ready to talk to. For normal use, see expect() and 
send() and sendline().

If the command parameter is an integer AND a valid file descriptor
then spawn will talk to the file descriptor instead. This can be
used to act expect features to any file descriptor. For example:
    fd = os.open ('somefile.txt', os.O_RDONLY)
    s = pexpect.spawn (fd)
The original creator of the file descriptor is responsible
for closing it. Spawn will not try to close it and spawn will
raise an exception if you try to call spawn.close().

Definition at line 134 of file pexpect.py.

00134                                                     :
        """This is the constructor. The command parameter may be a string
        that includes a command and any arguments to the command. For example:
            p = pexpect.spawn ('/usr/bin/ftp')
            p = pexpect.spawn ('/usr/bin/ssh user@example.com')
            p = pexpect.spawn ('ls -latr /tmp')
        You may also construct it with a list of arguments like so:
            p = pexpect.spawn ('/usr/bin/ftp', [])
            p = pexpect.spawn ('/usr/bin/ssh', ['user@example.com'])
            p = pexpect.spawn ('ls', ['-latr', '/tmp'])
        After this the child application will be created and
        will be ready to talk to. For normal use, see expect() and 
        send() and sendline().

        If the command parameter is an integer AND a valid file descriptor
        then spawn will talk to the file descriptor instead. This can be
        used to act expect features to any file descriptor. For example:
            fd = os.open ('somefile.txt', os.O_RDONLY)
            s = pexpect.spawn (fd)
        The original creator of the file descriptor is responsible
        for closing it. Spawn will not try to close it and spawn will
        raise an exception if you try to call spawn.close().
        """

        self.STDIN_FILENO = sys.stdin.fileno()
        self.STDOUT_FILENO = sys.stdout.fileno()
        self.STDERR_FILENO = sys.stderr.fileno()

        self.stdin = sys.stdin
        self.stdout = sys.stdout
        self.stderr = sys.stderr

        self.timeout = timeout
        self.child_fd = -1 # initially closed
        self.__child_fd_owner = None
        self.exitstatus = None
        self.pid = None
        self.log_file = None    
        self.before = None
        self.after = None
        self.match = None
        self.softspace = 0 # File-like object.
        self.name = '' # File-like object.
        self.flag_eof = 0

        # NEW -- to support buffering -- the ability to read more than one 
        # byte from a TTY at a time. See setmaxread() method.
        self.buffer = ''
        self.maxread = 1 # Maximum to read at a time
        ### IMPLEMENT THIS FEATURE!!!
        # anything before maxsearchsize point is preserved, but not searched.
        #self.maxsearchsize = 1000
        
        # If command is an int type then it must represent an open file descriptor.
        if type (command) == type(0):
            try: # Command is an int, so now check if it is a file descriptor.
                os.fstat(command)
            except OSError:
                raise ExceptionPexpect, 'Command is an int type, yet is not a valid file descriptor.'
            self.pid = -1 
            self.child_fd = command
            self.__child_fd_owner = 0 # Sets who is reponsible for the child_fd
            self.args = None
            self.command = None
            self.name = '<file descriptor>'
            return

        if type (args) != type([]):
            raise TypeError, 'The second argument, args, must be a list.'

        if args == []:
            self.args = _split_command_line(command)
            self.command = self.args[0]
        else:
            self.args = args
            self.args.insert (0, command)
            self.command = command
        self.name = '<' + reduce(lambda x, y: x+' '+y, self.args) + '>'

        self.__spawn()

    def __del__(self):


Generated by  Doxygen 1.6.0   Back to index