[debian/*.py] remove trailing whitespaces
Ignore-this: f62e84c258c847013d307d12acdf489e darcs-hash:20090309212356-0445d-d8338d06f968f316fcd085446023123be87040f7.gz
This commit is contained in:
parent
cc31727b60
commit
eae0d21f83
18 changed files with 352 additions and 352 deletions
|
@ -90,7 +90,7 @@ class spawn:
|
|||
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
|
||||
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
|
||||
|
@ -116,7 +116,7 @@ class spawn:
|
|||
self.__child_fd_owner = None
|
||||
self.exitstatus = None
|
||||
self.pid = None
|
||||
self.log_file = None
|
||||
self.log_file = None
|
||||
self.before = None
|
||||
self.after = None
|
||||
self.match = None
|
||||
|
@ -124,21 +124,21 @@ class spawn:
|
|||
self.name = '' # File-like object.
|
||||
self.flag_eof = 0
|
||||
|
||||
# NEW -- to support buffering -- the ability to read more than one
|
||||
# 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.pid = -1
|
||||
self.child_fd = command
|
||||
self.__child_fd_owner = 0 # Sets who is reponsible for the child_fd
|
||||
self.args = None
|
||||
|
@ -273,7 +273,7 @@ class spawn:
|
|||
|
||||
def setlog (self, fileobject):
|
||||
"""This sets logging output to go to the given fileobject.
|
||||
Set fileobject to None to stop logging.
|
||||
Set fileobject to None to stop logging.
|
||||
Example:
|
||||
child = pexpect.spawn('some_command')
|
||||
fout = file('mylog.txt','w')
|
||||
|
@ -300,13 +300,13 @@ class spawn:
|
|||
If a log file was set using setlog() then all data will
|
||||
also be written to the log file.
|
||||
|
||||
Notice that if this method is called with timeout=None
|
||||
Notice that if this method is called with timeout=None
|
||||
then it actually may block.
|
||||
|
||||
This is a non-blocking wrapper around os.read().
|
||||
It uses select.select() to implement a timeout.
|
||||
It uses select.select() to implement a timeout.
|
||||
"""
|
||||
|
||||
|
||||
if self.child_fd == -1:
|
||||
raise ValueError ('I/O operation on closed file')
|
||||
|
||||
|
@ -320,7 +320,7 @@ class spawn:
|
|||
if not r:
|
||||
self.flag_eof = 1
|
||||
raise EOF ('End Of File (EOF) in read(). Braindead platform.')
|
||||
|
||||
|
||||
r, w, e = select.select([self.child_fd], [], [], timeout)
|
||||
if not r:
|
||||
raise TIMEOUT('Timeout exceeded in read().')
|
||||
|
@ -338,21 +338,21 @@ class spawn:
|
|||
if s == '':
|
||||
self.flag_eof = 1
|
||||
raise EOF('End Of File (EOF) in read(). Empty string style platform.')
|
||||
|
||||
|
||||
if self.log_file != None:
|
||||
self.log_file.write (s)
|
||||
self.log_file.flush()
|
||||
|
||||
|
||||
return s
|
||||
|
||||
raise ExceptionPexpect('Reached an unexpected state in read().')
|
||||
|
||||
def read (self, size = -1): # File-like object.
|
||||
"""This reads at most size bytes from the file
|
||||
(less if the read hits EOF before obtaining size bytes).
|
||||
If the size argument is negative or omitted,
|
||||
read all data until EOF is reached.
|
||||
The bytes are returned as a string object.
|
||||
"""This reads at most size bytes from the file
|
||||
(less if the read hits EOF before obtaining size bytes).
|
||||
If the size argument is negative or omitted,
|
||||
read all data until EOF is reached.
|
||||
The bytes are returned as a string object.
|
||||
An empty string is returned when EOF is encountered immediately.
|
||||
"""
|
||||
if size == 0:
|
||||
|
@ -366,16 +366,16 @@ class spawn:
|
|||
# I would catch any bugs early and ensure consistant behavior.
|
||||
# It's a little less efficient, but there is less for me to
|
||||
# worry about if I have to later modify read() or expect().
|
||||
cre = re.compile('.{%d}' % size, re.DOTALL)
|
||||
cre = re.compile('.{%d}' % size, re.DOTALL)
|
||||
index = self.expect ([cre, EOF])
|
||||
if index == 0:
|
||||
return self.after ### self.before should be ''. Should I assert this?
|
||||
return self.before
|
||||
|
||||
|
||||
def readline (self, size = -1): # File-like object.
|
||||
"""This reads and returns one entire line. A trailing newline is kept in
|
||||
the string, but may be absent when a file ends with an incomplete line.
|
||||
Note: This readline() looks for a \\r\\n pair even on UNIX because this is
|
||||
the string, but may be absent when a file ends with an incomplete line.
|
||||
Note: This readline() looks for a \\r\\n pair even on UNIX because this is
|
||||
what the pseudo tty device returns. So contrary to what you may be used to
|
||||
you will receive a newline as \\r\\n.
|
||||
An empty string is returned when EOF is hit immediately.
|
||||
|
@ -404,9 +404,9 @@ class spawn:
|
|||
return result
|
||||
|
||||
def readlines (self, sizehint = -1): # File-like object.
|
||||
"""This reads until EOF using readline() and returns a list containing
|
||||
"""This reads until EOF using readline() and returns a list containing
|
||||
the lines thus read. The optional sizehint argument is ignored.
|
||||
"""
|
||||
"""
|
||||
lines = []
|
||||
while 1:
|
||||
line = self.readline()
|
||||
|
@ -422,7 +422,7 @@ class spawn:
|
|||
|
||||
def writelines (self, sequence): # File-like object.
|
||||
"""This calls write() for each element in the sequence.
|
||||
The sequence can be any iterable object producing strings,
|
||||
The sequence can be any iterable object producing strings,
|
||||
typically a list of strings. This does not add line separators
|
||||
There is no return value.
|
||||
"""
|
||||
|
@ -449,8 +449,8 @@ class spawn:
|
|||
buffer to be sent to the waiting child program without
|
||||
waiting for end-of-line. If it is the first character of the
|
||||
line, the read() in the user program returns 0, which
|
||||
signifies end-of-file. This means to work as expected
|
||||
a sendeof() has to be called at the begining of a line.
|
||||
signifies end-of-file. This means to work as expected
|
||||
a sendeof() has to be called at the begining of a line.
|
||||
This method does not send a newline. It is the responsibility
|
||||
of the caller to ensure the eof is sent at the beginning of a line.
|
||||
"""
|
||||
|
@ -487,7 +487,7 @@ class spawn:
|
|||
|
||||
# If this class was created from an existing file descriptor then
|
||||
# I just check to see if the file descriptor is still valid.
|
||||
if self.pid == -1 and not self.__child_fd_owner:
|
||||
if self.pid == -1 and not self.__child_fd_owner:
|
||||
try:
|
||||
os.fstat(self.child_fd)
|
||||
return 1
|
||||
|
@ -535,7 +535,7 @@ class spawn:
|
|||
|
||||
def compile_pattern_list(self, patterns):
|
||||
"""This compiles a pattern-string or a list of pattern-strings.
|
||||
Patterns must be a StringType, EOF, TIMEOUT, SRE_Pattern, or
|
||||
Patterns must be a StringType, EOF, TIMEOUT, SRE_Pattern, or
|
||||
a list of those.
|
||||
|
||||
This is used by expect() when calling expect_list().
|
||||
|
@ -569,7 +569,7 @@ class spawn:
|
|||
raise TypeError, 'Argument must be one of StringType, EOF, TIMEOUT, SRE_Pattern, or a list of those type. %s' % str(type(p))
|
||||
|
||||
return compiled_pattern_list
|
||||
|
||||
|
||||
def expect(self, pattern, timeout = -1):
|
||||
"""This seeks through the stream until a pattern is matched.
|
||||
The pattern is overloaded and may take several types including a list.
|
||||
|
@ -654,14 +654,14 @@ class spawn:
|
|||
#ED# incoming = ''
|
||||
incoming = self.buffer
|
||||
while 1: # Keep reading until exception or return.
|
||||
#ED# c = self.read_nonblocking (1, timeout)
|
||||
#ED# c = self.read_nonblocking (1, timeout)
|
||||
#ED# incoming = incoming + c
|
||||
|
||||
# Sequence through the list of patterns and look for a match.
|
||||
index = -1
|
||||
for str_target in pattern_list:
|
||||
index = index + 1
|
||||
if str_target is EOF or str_target is TIMEOUT:
|
||||
if str_target is EOF or str_target is TIMEOUT:
|
||||
continue # The Exception patterns are handled differently.
|
||||
match_index = incoming.find (str_target)
|
||||
if match_index >= 0:
|
||||
|
@ -670,9 +670,9 @@ class spawn:
|
|||
self.buffer = incoming [match_index + len(str_target):]
|
||||
self.match = None
|
||||
return index
|
||||
c = self.read_nonblocking (self.maxread, timeout)
|
||||
c = self.read_nonblocking (self.maxread, timeout)
|
||||
incoming = incoming + c
|
||||
|
||||
|
||||
except EOF:
|
||||
self.before = incoming
|
||||
self.after = EOF
|
||||
|
@ -695,10 +695,10 @@ class spawn:
|
|||
self.match = None
|
||||
self.buffer = ''
|
||||
raise
|
||||
|
||||
|
||||
def expect_list(self, pattern_list, timeout = -1):
|
||||
"""
|
||||
This takes a list of compiled regular expressions and returns
|
||||
This takes a list of compiled regular expressions and returns
|
||||
the index into the pattern_list that matched the child's output.
|
||||
This is called by expect(). It is similar to the expect() method
|
||||
except that expect_list() is not overloaded and it does not have to
|
||||
|
@ -711,7 +711,7 @@ class spawn:
|
|||
|
||||
if timeout == -1:
|
||||
timeout = self.timeout
|
||||
|
||||
|
||||
try:
|
||||
#ED# incoming = ''
|
||||
incoming = self.buffer
|
||||
|
@ -723,7 +723,7 @@ class spawn:
|
|||
index = -1
|
||||
for cre in pattern_list:
|
||||
index = index + 1
|
||||
if cre is EOF or cre is TIMEOUT:
|
||||
if cre is EOF or cre is TIMEOUT:
|
||||
continue # The patterns for PexpectExceptions are handled differently.
|
||||
match = cre.search(incoming)
|
||||
if match is not None:
|
||||
|
@ -735,7 +735,7 @@ class spawn:
|
|||
# Read more data
|
||||
c = self.read_nonblocking (self.maxread, timeout)
|
||||
incoming = incoming + c
|
||||
|
||||
|
||||
except EOF:
|
||||
self.before = incoming
|
||||
self.after = EOF
|
||||
|
@ -859,7 +859,7 @@ def _which (filename):
|
|||
|
||||
# Oddly enough this was the one line that made Pexpect
|
||||
# incompatible with Python 1.5.2.
|
||||
#pathlist = p.split (os.pathsep)
|
||||
#pathlist = p.split (os.pathsep)
|
||||
pathlist = string.split (p, os.pathsep)
|
||||
|
||||
for path in pathlist:
|
||||
|
@ -907,7 +907,7 @@ def _split_command_line(command_line):
|
|||
if c != '\\'and state_esc: # escape mode lasts for one character.
|
||||
state_esc = 0
|
||||
|
||||
# Handle last argument.
|
||||
# Handle last argument.
|
||||
if arg != '':
|
||||
arg_list.append(arg)
|
||||
return arg_list
|
||||
|
@ -936,7 +936,7 @@ def _split_command_line(command_line):
|
|||
# Nonblocking on Win32?
|
||||
# Reasearch this as a way to maybe make pipe work for Win32.
|
||||
# http://groups.google.com/groups?q=setraw+tty&hl=en&selm=uvgpvisvk.fsf%40roundpoint.com&rnum=7
|
||||
#
|
||||
#
|
||||
# if istty:
|
||||
# if os.name=='posix':
|
||||
# import tty
|
||||
|
@ -983,10 +983,10 @@ def _split_command_line(command_line):
|
|||
## self.buffer = ''
|
||||
##
|
||||
## def read(self, n, timeout = None):
|
||||
## """This does a read restricted by a timeout and
|
||||
## it includes any cached data from previous calls.
|
||||
## """This does a read restricted by a timeout and
|
||||
## it includes any cached data from previous calls.
|
||||
## This is a non-blocking wrapper around os.read.
|
||||
## it uses select.select to supply a timeout.
|
||||
## it uses select.select to supply a timeout.
|
||||
## Note that if this is called with timeout=None (the default)
|
||||
## then this actually MAY block.
|
||||
## """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue